Skip to main content

<MapView />

MapView backed by MapLibre Native

Props

PropTypeDefaultRequiredDescription
contentInsetnumber[] | numbernonefalseThe distance from the edges of the map view’s frame to the edges of the map view’s logical viewport.
styleViewProps["style"]nonefalseStyle for wrapping React Native View
mapStylestring | objectnonefalseStyle for map - either a URL or a Style JSON (https://maplibre.org/maplibre-style-spec/). Default: StyleURL.Default
preferredFramesPerSecondnumbernonefalseiOS: The preferred frame rate at which the map view is rendered.
The default value for this property is MLNMapViewPreferredFramesPerSecondDefault,
which will adaptively set the preferred frame rate based on the capability of
the user’s device to maintain a smooth experience. This property can be set to arbitrary integer values.

Android: The maximum frame rate at which the map view is rendered, but it can't excess the ability of device hardware.
This property can be set to arbitrary integer values.
localizeLabelsbooleanfalsefalseAutomatically change the language of the map labels to the system’s preferred language,
this is not something that can be toggled on/off
zoomEnabledbooleannonefalseEnable/Disable zoom on the map
scrollEnabledbooleantruefalseEnable/Disable scroll on the map
pitchEnabledbooleantruefalseEnable/Disable pitch on map
rotateEnabledbooleantruefalseEnable/Disable rotation on map
attributionEnabledbooleantruefalseEnable/Disable attribution on map.

This must be enabled for Mapbox-hosted tiles and styles. Please refer to the Mapbox Terms of Service.
Other providers do not require this.
attributionPosition{ top?: number; left?: number } | { top?: number; right?: number } | { bottom?: number; left?: number } | { bottom?: number; right?: number }nonefalseAdds attribution offset, e.g. {top: 8, left: 8} will put attribution button in top-left corner of the map
tintColorstring | unknown[]nonefalseMapView's tintColor
logoEnabledbooleanfalsefalseEnable/Disable the logo on the map.
logoPosition{ top?: number; left?: number } | { top?: number; right?: number } | { bottom?: number; left?: number } | { bottom?: number; right?: number }nonefalseAdds logo offset, e.g. {top: 8, left: 8} will put the logo in top-left corner of the map
compassEnabledbooleannonefalseEnable/Disable the compass from appearing on the map
compassViewPositionnumbernonefalseChange corner of map the compass starts at. 0: TopLeft, 1: TopRight, 2: BottomLeft, 3: BottomRight
compassViewMarginsobjectnonefalseAdd margins to the compass with x and y values
surfaceViewbooleanfalsefalse[Android only] Enable/Disable use of GLSurfaceView insted of TextureView.
onUserLocationUpdatefuncnonefalseThis event is triggered when the user location is updated.
signature:(location:Location) => void
regionWillChangeDebounceTimenumber10falseThe emitted frequency of regionwillchange events
regionDidChangeDebounceTimenumber500falseThe emitted frequency of regiondidchange events
childrenReactNodenonefalseFIX ME NO DESCRIPTION

Methods

getPointInView(coordinate)

Converts a geographic coordinate to a pixel point of the view.

Arguments

NameTypeRequiredDescription
coordinateGeoJSON.PositionYesGeographic coordinate
const pointInView = await mapViewRef.current?.getPointInView([
-37.81707, 144.949901,
]);

getCoordinateFromView(point)

Converts a pixel point of the view to a geographic coordinate.

Arguments

NameTypeRequiredDescription
pointtupleYesundefined
const coordinate = await mapViewRef.current?.getCoordinateFromView([100, 100]);

getVisibleBounds()

The coordinate bounds(ne, sw) visible in the users’s viewport.

const visibleBounds = await this._map.getVisibleBounds();

queryRenderedFeaturesAtPoint(point, [filter], [layerIDs])

Returns an array of rendered map features that intersect with a given point.

Arguments

NameTypeRequiredDescription
pointtupleYesundefined
filterFilterExpressionNoA set of strings that correspond to the names of layers defined in the current style. Only the features contained in these layers are included in the returned array.
layerIDsArrayNoA array of layer id's to filter the features by
this._map.queryRenderedFeaturesAtPoint(
[30, 40],
["==", "type", "Point"],
["id1", "id2"],
);

queryRenderedFeaturesInRect(bbox, [filter], [layerIDs])

Returns an array of rendered map features that intersect with the given rectangle,
restricted to the given style layers and filtered by the given predicate.

Arguments

NameTypeRequiredDescription
bboxGeoJSON.BBoxYesA rectangle expressed in the map view’s coordinate system.
filterFilterExpressionNoA set of strings that correspond to the names of layers defined in the current style. Only the features contained in these layers are included in the returned array.
layerIDsArrayNoA array of layer id's to filter the features by
this._map.queryRenderedFeaturesInRect(
[30, 40, 20, 10],
["==", "type", "Point"],
["id1", "id2"],
);

takeSnap([writeToDisk])

Takes snapshot of map with current tiles and returns a URI to the image

Arguments

NameTypeRequiredDescription
writeToDiskbooleanNoIf true will create a temp file, otherwise it is in base64

getZoom()

Returns the current zoom of the map view.

const zoom = await this._map.getZoom();

getCenter()

Returns the map's geographical centerpoint

const center = await this._map.getCenter();

setSourceVisibility(visible, sourceId, [sourceLayerId])

Sets the visibility of all the layers referencing the specified sourceLayerId and/or sourceId

Arguments

NameTypeRequiredDescription
visiblebooleanYesVisibility of the layers
sourceIdstringYesIdentifier of the target source (e.g. 'composite')
sourceLayerIdstringNoIdentifier of the target source-layer (e.g. 'building')
await this._map.setSourceVisibility(false, "composite", "building");

showAttribution()

Show the attribution and telemetry action sheet.
If you implement a custom attribution button, you should add this action to the button.