MapViewProps
Props for MapView.
This is an interface exported by @mapcairn/map, checked against version 0.2.0.
Signature
import type { MapViewProps } from "@mapcairn/map";
interface MapViewProps
Properties
basemap
readonly basemap: BasemapDefinition;
The active basemap. A change is applied to the mounted engine with setBasemap.
children
readonly children?: ReactNode;
Overlays and other content that reads the map through useMap.
chrome
readonly chrome?: (map: ReactNode) => ReactNode;
Renders the chrome around the map, inside the map context. It receives
the map region (with its hidden keyboard help) and returns the tree to
render in its place, so controls that call useMap, such as the scale
bar and the credits, can sit beside the map rather than inside it:
chrome={(map) => <MapChrome background={map} ... />}. Called on every
render; put hooks in the components it returns, not in the function.
cursor
readonly cursor?: MapCursor;
Defaults to grab.
id
readonly id?: string;
The id of the map region, for example the target of a skip link.
initialView
readonly initialView: ViewState;
The view the engine mounts with. Later changes are ignored.
keyHelp
readonly keyHelp?: readonly MapKeyHelpEntry[];
Extra lines for the hidden keyboard instructions, after the map's own, for the keys a tool adds while it is open. Descriptions are used as written, so write each as a complete sentence without a trailing full stop.
label
readonly label?: string;
The name of this map, in the language of the page, for a page with more
than one: "Pine" makes the map region "Map (Pine)", the search "Search
(Pine)", the map tools "Map tools (Pine)", and so on for the map scale,
the measuring and drawing toolbars and the credits, so no two landmarks
on the page share a name. Leave it out for a page with one map, where the
names stay as they are. A sheet's name is its title, which the host
writes.
onBasemapApplied
readonly onBasemapApplied?: (basemap: BasemapDefinition) => void;
Called when a change of basemap has loaded on the mounted engine, so
the app can save the choice only once it is known to work.
onBasemapError
readonly onBasemapError?: (error: MapEngineError, failed: BasemapDefinition, kept: BasemapDefinition) => void;
Called when a change of basemap could not load. The map keeps drawing
kept, the basemap that last loaded, and this is not an engine error:
useMap().error stays null. Passing kept back as basemap causes no
second swap.
onBasemapUnavailable
readonly onBasemapUnavailable?: (basemap: BasemapDefinition) => void;
Called when every tile of the basemap being drawn failed to load and none loaded, once the map settled (its provider is down). The map keeps working, so the host decides whether to draw another basemap instead.
onClick
readonly onClick?: (event: MapClickEvent) => void;
A click or tap on the map. Not called for the click that ends a long-press.
onDropPinKey
readonly onDropPinKey?: () => void;
The P key, which drops a pin at the centre of the map.
onEngineError
readonly onEngineError?: (error: MapEngineError, basemap: BasemapDefinition) => void;
Called when the engine cannot start or stops working. The app decides what to show, for example a message when WebGL is missing.
onEscape
readonly onEscape?: () => void;
The Escape key while the map has focus.
onIdentifyKey
readonly onIdentifyKey?: () => void;
The I key, which lists the features at the centre of the map.
onKeyCommand
readonly onKeyCommand?: (event: KeyboardEvent_2<HTMLElement>) => boolean;
Runs before the map's own keys, with each key pressed on the map region. Return true to say the key was handled: the map then does nothing with it and its default is prevented. A tool uses this to take keys the map would otherwise use, such as the arrows that move a selected point.
onLongPress
readonly onLongPress?: (event: MapLongPressEvent) => void;
A long-press (touch or mouse) or a right-click.
onPointerMove
readonly onPointerMove?: (latlng: LatLng | null) => void;
The position under a mouse or pen, at most once per frame, or null when
it leaves the map. For the cursor coordinates readout; touch is ignored.
Leaving the map for MapReadout reports nothing, so the coordinates stay
put while the readout grows under the pointer: pass MapReadout an
onCursorLeave that clears the position, or it stays shown after the
pointer leaves the readout.
onViewChange
readonly onViewChange?: (view: ViewState) => void;
Called when the view stops changing (moveEnd), not on every frame.
testId
readonly testId?: string;
Sets data-testid on the map region.