API Reference

← Back | Components →


<Map />

PropTypeDefaultDescription
center{ lat, lon }requiredInitial map center
zoomnumber10Initial zoom level (1–20)
themestring | MapTheme"coral"See theming
heightstring"100%"CSS height of map container
widthstring"100%"CSS width of map container
onMove(center, zoom) => voidFires when map is panned/zoomed
onClick({ lat, lon }) => voidFires on map click
childrenReactNode<Marker>, <Route>, <Polygon> etc.

<Marker />

PropTypeDefaultDescription
latnumberrequiredLatitude
lonnumberrequiredLongitude
colorstring"#e74c3c"Marker pin color
labelstringText label below marker
iconstring"pin"Icon name or URL
sizenumber24Marker size in px
childrenReactNode<Popup> content

<Route />

PropTypeDefaultDescription
points{ lat, lon }[]requiredOrdered coordinate list
colorstring"#3498db"Line color
widthnumber3Line width in px
dashedbooleanfalseDashed line style

<Polygon />

PropTypeDefaultDescription
coordinates{ lat, lon }[]requiredPolygon vertices
fillColorstring"rgba(52,152,219,0.2)"Fill color
borderColorstring"#3498db"Border color
borderWidthnumber2Border width in px

<SearchBox />

PropTypeDescription
onSelect(loc: Location) => voidCalled with selected location
placeholderstringInput placeholder text
type Location = {
  name: string
  lat: number
  lon: number
}

useMap() Hook

Must be used inside a <Map /> tree.

const { flyTo, setZoom, getCenter, getBounds } = useMap()
 
flyTo({ lat: 48.8, lon: 2.3, zoom: 14 })
setZoom(10)
const center = getCenter()   // { lat, lon }
const bounds = getBounds()   // { north, south, east, west }