Skip to main content

Interface: ProximitySearch

Defined in: spec/types.proximity.ts:70

A search for the places within a radius of a feature the reader clicks — or, with fromUserLocation, of where the reader is, and with fromAnyPoint, of any point of the map the reader clicks.

Clicking a feature of one of layers calls query with its position. While the search runs, a circle of the radius sweeps around the feature; the answers then drop in as pins of their category, and a bar under the circle counts them, offers the other radii and clears the search. Clicking the same feature again clears it too.

While a search is shown, the clicked pin is the only one of the map's pins left — every symbol layer is hidden, and the clicked pin is drawn above the circle, grown a little — and clearing the search brings back the pins of every layer that is on, the clicked one at its own size.

Properties​

categories?​

optional categories?: ProximityCategory[]

Defined in: spec/types.proximity.ts:95

The kinds of place the answers belong to, and how their pins look.


frame?​

optional frame?: "fill" | "compact"

Defined in: spec/types.proximity.ts:132

How large the camera frames the circle of a search: 'fill' (the default) zooms until the circle fills most of the map's free area — the map less viewInsets — leaving room for the bar under it; 'compact' keeps it between 110 and 150 px across, the map around it in view.


fromAnyPoint?​

optional fromAnyPoint?: boolean

Defined in: spec/types.proximity.ts:125

Adds a button under the map's controls that turns on searching from any point of the map the reader clicks, not only from a feature of layers. While it is on, the cursor is a crosshair off the pins; a click marks the point with a dot, and the bar reads "near this point". The search turns the button off, so searching from another point takes the button again; the bar's ×, or the dot, clears the search. Turning the button off by hand keeps the search shown too.

A click keeps its other meanings first — a feature of layers still searches from itself, and a feature of a layer that declares click or clickAnchor still opens its own card — and a double-click still zooms. Defaults to false.


fromUserLocation?​

optional fromUserLocation?: boolean

Defined in: spec/types.proximity.ts:110

Adds a button under the map's controls that searches from the reader's own location: it explains why the location is needed, asks the browser for it, and runs the same search from there, marking the reader with a blue dot. Clicking it again clears the search. Hidden where the browser offers no geolocation, as outside HTTPS. Defaults to false: asking for the reader's location is the app's choice, not the search's.


initialRadius?​

optional initialRadius?: number

Defined in: spec/types.proximity.ts:93

The radius the first search uses, in metres — one of radii. Defaults to the smallest.


labels?​

optional labels?: object

Defined in: spec/types.proximity.ts:101

How the texts name what is searched, singular and plural — e.g. serviço and serviços read "Buscar serviços em 1 km", "3 serviços em até 1 km". Defaults to the translated "result" and "results".

one?​

optional one?: string

other?​

optional other?: string


layers?​

optional layers?: string[]

Defined in: spec/types.proximity.ts:77

Ids of the layers whose features start a search when clicked — e.g. the hospitals' pins. A point feature is searched from its own position; any other, from where the click landed. Optional only with fromAnyPoint, where any point of the map starts one.


query​

query: (params) => Promise<ProximityResult[]>

Defined in: spec/types.proximity.ts:83

Finds the places within a ring around a point — see ProximityQueryParams. Only callable from code: a spec written as JSON cannot carry it.

Parameters​

ParameterType
paramsProximityQueryParams

Returns​

Promise<ProximityResult[]>


radii?​

optional radii?: number[]

Defined in: spec/types.proximity.ts:88

The radii the reader can choose between, in metres, ascending. Defaults to [1000, 2000, 3000].