Knit UI
GitHub

Playground

Loading playground…

true
true
false
false
true
true
true
true
Playground
<Map
  mapStyle={DEMO_STYLE}
  compass
  attribution
  logo={false}
  scaleBar={false}
  dragPan
  touchZoom
  touchRotate
  touchPitch
/>

Examples

Basic

The simplest possible map — a style and an initial camera position.

Loading example…

BasicSourceStorybook

Streets Basemap

A vector basemap with streets and labels (Carto Positron).

Loading example…

Streets BasemapSourceStorybook

Minimal

Ornaments toggled off for an embedded / minimal look.

Loading example…

MinimalSourceStorybook

Static

Gestures disabled — a static, non-interactive map.

Loading example…

StaticSourceStorybook

Props

PropTypeDefaultDescription
mapStyle requiredstring | maplibregl.StyleSpecification
demo · streets
MapLibre style URL or JSON style object.
androidView"surface" | "texture" | undefinedAndroid rendering mode.
attributionboolean | AttributionControlOptions | undefinedtrueShow the attribution control.
attributionPositionOrnamentViewPosition | undefined
childrenReactNode
classNamestring | undefined
compassboolean | undefinedtrueShow the compass ornament.
compassHiddenFacingNorthboolean | undefined
compassPositionOrnamentViewPosition | undefined
contentInsetViewPadding | undefinedDistance from view edges to logical viewport.
doubleTapHoldZoomboolean | undefined
doubleTapZoomboolean | undefined
dragPanboolean | undefinedtrue
lightmaplibregl.LightSpecification | undefinedLight properties for extruded geometries.
logoboolean | undefinedfalse
logoPositionOrnamentViewPosition | undefined
onDidFailLoadingMap(() => void) | undefined
onDidFinishLoadingMap(() => void) | undefined
onDidFinishLoadingStyle(() => void) | undefined
onDidFinishRenderingFrame(() => void) | undefined
onDidFinishRenderingFrameFully(() => void) | undefined
onDidFinishRenderingMap(() => void) | undefined
onDidFinishRenderingMapFully(() => void) | undefined
onLongPress((event: PressEvent) => void) | undefined
onPress((event: PressEvent | PressEventWithFeatures) => void) | undefined
onRegionDidChange((event: ViewStateChangeEvent) => void) | undefinedFires once, after the viewport settles. The right place for `setState`.
onRegionIsChanging((event: ViewStateChangeEvent) => void) | undefinedFires continuously while the viewport changes, throttled to ~32 ms (≈30×/s). **Do not `setState` from this handler unthrottled.** Every state update re-renders the whole map subtree, and a re-render is the amplifier for the expensive work in the children: `GeoJSONSource` re-serializes its FeatureCollection on native, and layers re-resolve their paint/layout. Those paths are memoized on their inputs, so a re-render is cheap only as long as the props you hand them keep their value — pass stable `data`/`style`/`filter` objects (`useMemo`) if you re-render during a gesture at all. Prefer keeping live viewport values in a ref, or debouncing to `onRegionDidChange`.
onRegionWillChange((event: ViewStateChangeEvent) => void) | undefinedFires once per gesture, when the viewport starts changing.
onWillStartLoadingMap(() => void) | undefined
onWillStartRenderingFrame(() => void) | undefined
onWillStartRenderingMap(() => void) | undefined
platformPropsPlatformProps | undefined
preferredFramesPerSecondnumber | undefinediOS: adaptive FPS. Android: max FPS.
scaleBarboolean | undefinedfalse
scaleBarPositionOrnamentViewPosition | undefined
styleunknown
testIDstring | undefined
tintColorstring | undefined
touchPitchboolean | undefinedtrue
touchRotateboolean | undefinedtrue
touchZoomboolean | undefinedtrue
Accessibility & DOM props (2)
PropType
keyKey | null | undefined
refRef<MapRef> | undefined