Map
ProNewA map with custom markers, an info card and a searchable location list. The street surface is drawn in the browser, so it needs no key and makes no requests; supply your own tiles or surface for real cartography.
Installation
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
Props
<MapView>
| Prop | Type | Default |
|---|---|---|
| locations* | MapLocation[] | — |
| selectedId | string | nullThe open location. Leave it out to let the map manage it. | — |
| onSelect | (id: string | null) => void | — |
| center | LatLngStarting center. Without it the map fits every location. | — |
| zoom | numberStarting zoom, 2 (world) to 19 (building). | — |
| minZoom | number | 2 |
| maxZoom | number | 19 |
| focusZoom | numberZoom used when a location is opened; the map never zooms out to reach it. | 13 |
| mapStyle | MapStyle`auto` follows the page theme. | "auto" |
| markerStyle | MarkerStyle | "pin" |
| accent | stringMarker and highlight color, any CSS color. | "#e5484d" |
| accentForeground | stringText and glyph color on top of the accent. | "#fff" |
| route | boolean | LatLng[]Join the locations in order with a line, or pass the points of your own path. | — |
| userLocation | LatLngA pulsing dot for the visitor's position. | — |
| controls | booleanZoom and reset buttons. | true |
| scrollZoom | booleanZoom with the wheel alone. Off by default so the page keeps scrolling; Ctrl or ⌘ + wheel always zooms. | false |
| tiles | stringA raster tile URL with `{z}`, `{x}` and `{y}`, for example your own tile server. Leave it out for the built-in street surface. | — |
| attribution | React.ReactNodeCredit line for the tiles, bottom right. | — |
| renderSurface | (context: MapSurfaceContext) => React.ReactNodeDraw the surface yourself: a static image, canvas, or another map library kept in step with `center` and `zoom`. | — |
| padding | InsetsSpace covered by your own overlays; fitting and focusing keep markers out of it. | — |
| renderPopup | (location: MapLocation, close: () => void) => React.ReactNodeContent of the card above the open marker. Return null for none. | — |
| label | stringAccessible name of the map. | "Locations" |
| loading | boolean | — |
| className | string | — |
| children | React.ReactNodeOverlays drawn above the map. | — |
<Map>
| Prop | Type | Default |
|---|---|---|
| locations* | MapLocation[] | — |
| label | stringAccessible name of the widget and its map. | "Locations" |
| list | "left" | "right" | "none"Where the location list sits. On narrow containers it becomes a drawer under the map. | "left" |
| searchable | booleanA search field above the list, filtering by name, address and category. | true |
| searchPlaceholder | string | "Search locations" |
| defaultListOpen | booleanStart with the list open. Defaults to open when there is room beside the map. | — |
| selectedId | string | nullThe open location, for controlled use. | — |
| defaultSelectedId | stringA location to open on first render. | — |
| onSelect | (id: string | null) => void | — |
| height | number | stringHeight in pixels, or any CSS length. | 520 |
| getDirectionsUrl | (location: MapLocation) => stringWhere the Directions button goes. Defaults to a Google Maps directions link. | directionsUrl |
| className | string | — |
Accessibility
- The map is a focusable region: arrow keys pan, plus and minus zoom, zero fits every location.
- Every marker is a button named after its place; its card follows it in the tab order and Escape closes it.
- The list is real buttons and links, and a status line reports how many places match a search.
- Supplied website addresses become links only when they resolve to HTTP(S); unsafe schemes remain plain text.
- Under 640px the list becomes a drawer under the map. Panning and zooming jump instead of gliding under reduced motion.