MapView
MapView backed by Mapbox Native GL. This is the core component that renders the map.Import
Basic Usage
Props
projection
The projection used when rendering the map.
styleURL
Style URL for map. If none is set, it will default to
Mapbox.StyleURL.Street.styleJSON
StyleJSON for map according to TileJSON specs.
preferredFramesPerSecond
iOS: The preferred frame rate at which the map view is rendered. The default value adapts based on the device capability.Android: The maximum frame rate at which the map view is rendered, limited by device hardware capability.This property can be set to arbitrary integer values.
zoomEnabled
Enable or disable zoom gestures on the map.
scrollEnabled
Enable or disable scroll/pan gestures on the map.
pitchEnabled
Enable or disable pitch gestures on the map.
maxPitch
Maximum allowed pitch in degrees. Mirrors the Mapbox map option
maxPitch.rotateEnabled
Enable or disable rotation gestures on the map.
attributionEnabled
Enable or disable attribution on the map.
attributionPosition
Adds attribution offset. For example,
{top: 8, left: 8} will put the attribution button in the top-left corner of the map.By default:- Android: Attribution with information icon (i) on bottom left
- iOS: Mapbox logo on bottom left, information icon (i) on bottom right
tintColor
MapView’s tint color.
logoEnabled
Enable or disable the Mapbox logo on the map.
logoPosition
Adds logo offset. For example,
{top: 8, left: 8} will put the logo in the top-left corner of the map.compassEnabled
Enable or disable the compass from appearing on the map.
compassFadeWhenNorth
Enable or disable the compass fading out when the map is pointing north. V10+ only.
compassPosition
Adds compass offset. For example,
{top: 8, left: 8} will put the compass in the top-left corner of the map. V10+ only.compassViewPosition
Change corner of map the compass starts at:
0: TopLeft1: TopRight2: BottomLeft3: BottomRight
compassViewMargins
Add margins to the compass with x and y values.
compassImage
A string referencing an image key. Requires an
Images component. iOS only, V10+ only.scaleBarEnabled
Enable or disable the scale bar from appearing on the map. V10+ only.
scaleBarPosition
Adds scale bar offset. For example,
{top: 8, left: 8} will put the scale bar in the top-left corner of the map. V10+ only.surfaceView
Enable or disable use of GLSurfaceView instead of TextureView. Android only.
requestDisallowInterceptTouchEvent
Experimental: Call requestDisallowInterceptTouchEvent on parent with onTouchEvent. This allows touch interaction to work when embedded into a scroll view. Android only.
localizeLabels
Set map’s label locale. V10+ only.
{ locale: "es" }- Localize labels to Spanish{ locale: "current" }- Localize labels to system localetrue- Equivalent to{ locale: "current" }
layerIds to localize only specific layers.gestureSettings
Gesture configuration to control user touch interaction.GestureSettings Properties:
doubleTapToZoomInEnabled?: boolean- Double tap with one touch to zoom indoubleTouchToZoomOutEnabled?: boolean- Single tap with two touches to zoom outpinchPanEnabled?: boolean- Pan/scroll for pinch gesturepinchZoomEnabled?: boolean- Zoom for pinch gesturepinchZoomDecelerationEnabled?: boolean- Deceleration animation after pinch-zoom (Android only)pitchEnabled?: boolean- Pitch gesture enabledquickZoomEnabled?: boolean- Quick zoom gesture enabledrotateEnabled?: boolean- Rotate gesture enabledrotateDecelerationEnabled?: boolean- Deceleration animation after rotate (Android only)panEnabled?: boolean- Single-touch pan/scroll gesturepanDecelerationFactor?: number- Pan deceleration speed factorsimultaneousRotateAndPinchZoomEnabled?: boolean- Rotation during pinch zoomzoomAnimationAmount?: number- Zoom level change during double-tap gestures (Android only)
contentInset
The distance from the edges of the map view’s frame to the edges of the map view’s logical viewport.
deselectAnnotationOnTap
Set to true to deselect any selected annotation when the map is tapped. If set to true, you will not receive the onPress event for taps that deselect an annotation.
Events
onPress
Called when a user presses the map.
onLongPress
Called when a user long presses the map.
onCameraChanged
Called whenever the map camera is changing. V10+ only, replaces onRegionIsChanging.
onMapIdle
Called when the map becomes idle after camera movement. V10+ only, replaces onRegionDidChange.
onRegionWillChange
Called when the displayed map region is about to change.
onRegionIsChanging
Called when the displayed map region is changing.
onRegionDidChange
Called when the displayed map region finished changing.
onWillStartLoadingMap
Called when the map is about to start loading a new style.
onDidFinishLoadingMap
Called when the map has successfully loaded a new style.
onMapLoadingError
Called when there is an error during map load. V10+ only, replaces onDidFailLoadingMap.
onDidFailLoadingMap
Called when the map has failed to load a new style.
onWillStartRenderingFrame
Called when the map will start rendering a frame.
onDidFinishRenderingFrame
Called when the map finished rendering a frame.
onDidFinishRenderingFrameFully
Called when the map fully finished rendering a frame.
onWillStartRenderingMap
Called when the map will start rendering.
onDidFinishRenderingMap
Called when the map finished rendering.
onDidFinishRenderingMapFully
Called when the map fully finished rendering.
onUserLocationUpdate
Called when the user location is updated.
onDidFinishLoadingStyle
Called when a style has finished loading.
regionWillChangeDebounceTime
The emitted frequency of regionwillchange events in milliseconds.
regionDidChangeDebounceTime
The emitted frequency of regiondidchange events in milliseconds.
Methods
To use imperative methods, create a ref:getPointInView()
getCoordinateFromView()
getVisibleBounds()
queryRenderedFeaturesAtPoint()
queryRenderedFeaturesInRect()
querySourceFeatures()
takeSnap()
getZoom()
getCenter()
clearData()
queryTerrainElevation()
setSourceVisibility()
setFeatureState()
getFeatureState()
removeFeatureState()
stateKey is null, all properties are removed.
Examples
- Basic Map
- With Gestures
- Globe Projection
- With Methods
Related Components
- Camera - Control the map camera
- UserLocation - Show user location
- StyleImport - Configure standard style