Skip to main content

UseSearchOptions

Options for useSearch.

This is an interface exported by @mapcairn/map, checked against version 0.2.0.

Signature​

import type { UseSearchOptions } from "@mapcairn/map";

interface UseSearchOptions

Properties​

getBias​

readonly getBias?: () => Bounds | undefined;

Returns the box to favour results inside, usually the visible map. Called once when each search starts, so the bias follows the map without the caller recomputing it on every frame. Leave it out to send only the query: a host that passes it sends that box to its geocoder with every search, which can show where the person is, so its privacy text must say so.

onPick​

readonly onPick?: (result: SearchResult) => boolean;

Takes the result when a search finds exactly one place, so Enter goes straight to it instead of opening a list of one. The box then shows the place's label with nothing to choose, and the announcement says where the map went, not how many results there were. It returns false to decline (the person has moved on from the box, say), and the result then shows as a list. Several results always become a list, and without this option a single result does too.

See also​

Source: packages/map/src/tools/SearchPill/useSearch.ts:38