GeoMap
A geographic map that renders on the server.
View code
<GeoMap
id="stays-map"
label="Stays on Ilha Nova"
center={[-32, 44]}
zoom={11}
basemap={{ kind: "geojson", data: island, ground: "water" }}
controls={["zoom", "fullscreen"]}
labels={labels}
>
{stays.map((stay) => (
<GeoMap.Marker at={stay.at} label={stay.price} mapKey={stay.id} current={stay.id === selected}>
<GeoMap.Popup>
<StayCard stay={stay} />
</GeoMap.Popup>
</GeoMap.Marker>
))}
</GeoMap>Installation
An ordinary dependency: install it, import the theme once, and import the component where it is used.
npm add @sdxc/ui remiximport "@sdxc/ui/theme.css";Usage
import { GeoMap } from "@sdxc/ui/map";The map stage: a region at the full size of its parent (20rem tall at least) that draws the basemap as SVG, writes place names, clusters close markers into bubbles and shows the controls, then hands the stage to the island, which mounts MapLibre in it when WebGL works.
Composition
The parts the component publishes, each a static property of the host.
GeoMapGeoMap.MarkerOne marker: a pill whose tail tips onto its point, as a link withhrefor a button otherwise.GeoMap.PopupA card a marker opens, anchored above its pin with CSS anchor positioning and flipped below when the top has no room.GeoMap.RouteDraws a route along real coordinates: a light casing, the whole line dashed and the travelled share solid on top.GeoMap.RouteMarkerPlaces a glyph along its route with CSS motion paths.GeoMap.AreaA "Search this area" button for a search form: hidden fields carry the bounds, middle and zoom the page was drawn at, and once the visitor pans or zooms, the island rewrites them and reveals the button, which submits the form named byform.
Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
| Prop | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The stage's id, which the island finds it by. |
label | string | Yes | The map's accessible name, such as "Stays in Lisbon". |
center | LngLat | Yes | The point at the middle of the stage. |
zoom | number | Yes | |
minZoom | number | No | |
maxZoom | number | No | |
basemap | Basemap | No | What the map is drawn on: a MapLibre style pair, or your own GeoJSON. |
controls | Control[] | No | |
navigation | Navigation | No | Turns zoom controls and clusters into links that work without script. |
labels | Labels | Yes | |
clusterRadius | number | No | Distance in pixels under which markers gather into one bubble. |
viewport | Pixel | No | Stage size in pixels assumed on the server for the bounds a search area submits. |
workerUrl | string | No | Where the island loads MapLibre's worker from, such as a bundler's ?url import. |
children | RemixNode | No | GeoMap.Marker, GeoMap.Route and GeoMap.Area elements. |
Also accepts everything in Omit<TagProps<"div">, "children" | "id">.
GeoMap.Marker
| Prop | Type | Required | Description |
|---|---|---|---|
mix | TagProps<"span">["mix"] | No | Mixins for the marker, which renders as either a link or a button. |
at | LngLat | Yes | |
label | RemixNode | Yes | The pill's content, such as a price; with text it names the marker. |
href | string | No | Renders the marker as a link; a popup then opens on hover and focus. |
highlighted | boolean | No | Lights the marker as if pointed at, such as while its listing is hovered. |
current | boolean | No | Marks the selected marker: inverted colors, drawn above the rest, never clustered. |
tone | "brand" | "neutral" | No | |
mapKey | string | No | Record key shared with a listing row, linked through mapLink. |
children | RemixNode | No | A GeoMap.Popup. |
Also accepts everything in Omit<TagProps<"button">, "children" | "mix">.
GeoMap.Popup
| Prop | Type | Required | Description |
|---|---|---|---|
children | RemixNode | No |
Also accepts everything in Omit<TagProps<"div">, "id" | "popover" | "style">.
GeoMap.Route
| Prop | Type | Required | Description |
|---|---|---|---|
path | LngLat[] | Yes | |
progress | number | No | Share of the route travelled, from 0 to 1, drawn solid; the rest is dashed. |
children | RemixNode | No | GeoMap.RouteMarker elements. |
Also accepts everything in Omit<TagProps<"svg">, "children" | "viewBox">.
GeoMap.RouteMarker
| Prop | Type | Required | Description |
|---|---|---|---|
at | "progress" | "start" | "end" | No | progress follows the route's progress and the live --ui-map-progress property; a number is a fixed share. |
children | RemixNode | No | SVG glyph centred on the origin; a dot with a halo when omitted. |
Also accepts everything in Omit<TagProps<"g">, "children" | "style">.
GeoMap.Area
| Prop | Type | Required | Description |
|---|---|---|---|
form | string | Yes | The id of the form the fields and the button belong to. |
label | RemixNode | Yes | The button's content, such as "Search this area". |
name | string | No | Field receiving west,south,east,north. |
centerName | string | No | Field receiving longitude,latitude of the middle. |
zoomName | string | No | Field receiving the zoom. |
Also accepts everything in Omit<TagProps<"button">, "children" | "form" | "type">.
Types
| Name | Values | What it decides |
|---|---|---|
Control | "zoom" | "reset" | "locate" | "fullscreen" | A control the map can show in its top corner. |