SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

GeoMap

A geographic map that renders on the server.

Casa do LagoTwo bedrooms by the water · sleeps four$240 a night
View code
tsx
<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.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Usage

typescript
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.

  • GeoMap
  • GeoMap.MarkerOne marker: a pill whose tail tips onto its point, as a link with href or 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 by form.

Props

Read from the component's own types, so every prop, every default and every allowed value is listed.

PropTypeRequiredDescription
idstringYesThe stage's id, which the island finds it by.
labelstringYesThe map's accessible name, such as "Stays in Lisbon".
centerLngLatYesThe point at the middle of the stage.
zoomnumberYes
minZoomnumberNo
maxZoomnumberNo
basemapBasemapNoWhat the map is drawn on: a MapLibre style pair, or your own GeoJSON.
controlsControl[]No
navigationNavigationNoTurns zoom controls and clusters into links that work without script.
labelsLabelsYes
clusterRadiusnumberNoDistance in pixels under which markers gather into one bubble.
viewportPixelNoStage size in pixels assumed on the server for the bounds a search area submits.
workerUrlstringNoWhere the island loads MapLibre's worker from, such as a bundler's ?url import.
childrenRemixNodeNoGeoMap.Marker, GeoMap.Route and GeoMap.Area elements.

Also accepts everything in Omit<TagProps<"div">, "children" | "id">.

GeoMap.Marker

PropTypeRequiredDescription
mixTagProps<"span">["mix"]NoMixins for the marker, which renders as either a link or a button.
atLngLatYes
labelRemixNodeYesThe pill's content, such as a price; with text it names the marker.
hrefstringNoRenders the marker as a link; a popup then opens on hover and focus.
highlightedbooleanNoLights the marker as if pointed at, such as while its listing is hovered.
currentbooleanNoMarks the selected marker: inverted colors, drawn above the rest, never clustered.
tone"brand" | "neutral"No
mapKeystringNoRecord key shared with a listing row, linked through mapLink.
childrenRemixNodeNoA GeoMap.Popup.

Also accepts everything in Omit<TagProps<"button">, "children" | "mix">.

GeoMap.Popup

PropTypeRequiredDescription
childrenRemixNodeNo

Also accepts everything in Omit<TagProps<"div">, "id" | "popover" | "style">.

GeoMap.Route

PropTypeRequiredDescription
pathLngLat[]Yes
progressnumberNoShare of the route travelled, from 0 to 1, drawn solid; the rest is dashed.
childrenRemixNodeNoGeoMap.RouteMarker elements.

Also accepts everything in Omit<TagProps<"svg">, "children" | "viewBox">.

GeoMap.RouteMarker

PropTypeRequiredDescription
at"progress" | "start" | "end"Noprogress follows the route's progress and the live --ui-map-progress property; a number is a fixed share.
childrenRemixNodeNoSVG glyph centred on the origin; a dot with a halo when omitted.

Also accepts everything in Omit<TagProps<"g">, "children" | "style">.

GeoMap.Area

PropTypeRequiredDescription
formstringYesThe id of the form the fields and the button belong to.
labelRemixNodeYesThe button's content, such as "Search this area".
namestringNoField receiving west,south,east,north.
centerNamestringNoField receiving longitude,latitude of the middle.
zoomNamestringNoField receiving the zoom.

Also accepts everything in Omit<TagProps<"button">, "children" | "form" | "type">.

Types

NameValuesWhat it decides
Control"zoom" | "reset" | "locate" | "fullscreen"A control the map can show in its top corner.
@sdxc/ui

Can’t find it? Contact us