Skip to content

Places ​

Show places on a map the host draws. Give a place as lat and lon in decimal degrees. A host that looks addresses up (see Looking up an address) also accepts an address. A block cannot name tiles, a map URL, a style or a vendor.

tsx
import { useState } from 'react';
import { bound, ui } from '../shared/intelligent-ui-tree.ts';
import { DemoBlock } from '../shared/intelligent-ui.tsx';

export default function PlacesDemo() {
    const [picked, setPicked] = useState<unknown>('');

    return (
        <DemoBlock
            nodes={[
                bound(
                    ui(
                        'Map',
                        {},
                        ui('Place', { lat: 52.0907, lon: 5.1214, value: 'dom', detail: 'Climb the tower' }, 'Domtoren'),
                        ui('Place', { address: 'Oudegracht 245, Utrecht', value: 'gracht' }, 'Oudegracht'),
                        ui('Place', { lat: 52.0894, lon: 5.1103, value: 'station' }, 'Station')
                    ),
                    picked,
                    setPicked
                )
            ]}
            context={{ place: (nodeId) => (nodeId.endsWith('.1') ? { lat: 52.0849, lon: 5.1181 } : undefined) }}
        />
    );
}
ui
$picked = ""
<Map value={$picked}>
<Place lat={52.0907} lon={5.1214} value="dom" detail="Climb the tower">Domtoren</Place>
<Place address="Oudegracht 245, Utrecht" value="gracht">Oudegracht</Place>
<Place lat={52.0894} lon={5.1103} value="station">Station</Place>
</Map>
<Choices><Choice context={"Plan the walk around " + $picked}>Plan the walk</Choice></Choices>

Map ​

One to 50 places, with a numbered list under the map; the compiler refuses more. After Each or Show, a Map that draws none fails as a whole, and one that draws more than 50 shows the first 50 with too_many_children and a count of the rest (UiViewNode.omitted). The list is the accessible form of the map and holds every place, also those without a point.

PropTypeRequiredNotes
valuescalarNoBindable; the value of the place a person picked

A bound Map is an input: each row whose Place has a value is a button that sets the binding. A Choice carries the value only when a place of that map offers it, or when it is still the default.

Place ​

One place. It stands only inside Map, and its children are the name.

PropTypeRequiredNotes
latnumberWith lonFrom -90 to 90
lonnumberWith latFrom -180 to 180
addressstringOr lat and lonAt most 512 characters; read only by a host that looks addresses up
detailstringNoA line under the name
valuescalarNoWhat picking the place sets on the bound Map

A Place with only one of lat and lon, or with neither coordinates nor an address, fails alone and draws as its text. With both, the host's lookup wins when it has one; lat and lon stand until it answers or when it finds nothing.

Looking up an address ​

Neither this package nor @adecore/agents looks anything up. The instructions for the agent ask for coordinates unless the host says it can do more: pass places: 'addresses' to uiSessionNote, uiReferenceText, uiGroupReference or uiGroupDescription and they allow an address again (see the catalog in code).

A renderer shows what the host hands it. UiRenderContext.place(nodeId, address) returns the host's point for that address: undefined while there is none, and null for an address without a point. A reading applies only to the address it was made for. The list says Looking up for undefined and Not on the map for null, without a marker. A host that has points for addresses writes them into uiQueries.blocks[id].places (ChatUiPlaceReading in @adecore/agent-contracts).

What the host draws ​

The renderer draws the host's tiles when it has them, otherwise a world outline (Natural Earth 110m land, public domain) that zooms no closer than about a country. The numbered list always stands under it. The picture is not saved with the block. A third button beside the zoom buttons fits every place in view, and overlapping markers spread apart.

Fallback ​

A Map falls back to a numbered list, one line per drawn place: 1. Domtoren (52.0907, 5.1214): Climb the tower. A failed place stays unnumbered, as its text.

Licenses and third-party notices are listed in each package.