Skip to content
tsx
import Mapa from 'react-native-mapa';
// or import { MapView, Camera } from 'react-native-mapa';

<Mapa.MapView>
 <Mapa.Camera pitch={60} />
</Mapa.MapView>

MapView ​

Props ​

projection? ​

optional projection: "mercator" | "globe"

Coordinate projection system

style? ​

optional style: 'AmapSatellite' | 'AmapSatellite' | 'MapboxVector' | 'MapboxSatellite'

Map style, supports AMap vector map, AMap satellite map, Mapbox vector map, Mapbox satellite map. Default is AMap vector map.

To customize the base map, you can use the Background component.

onPress() ​

optional onPress: (feature) => void

Map click event

Parameters ​

• feature: PressFeature

Click location information

onLongPress()? ​

optional onLongPress: (feature) => void

Long press map event

Example ​

{
 "geometry": {"coordinates": [104.06190928823503, 30.657739121986168], "type": "Point"},
 "properties": {"screenPointX": 197.3333282470703, "screenPointY": 372.3333333333333},
 "type": "Feature"
}

Parameters ​

• feature: PressFeature

onMapIdle()? ​

optional onMapIdle: (e) => void

Triggered when the map is idle

Parameters ​

• e: MapIdleEvent

Methods ​

getCenter() ​

Get the center coordinates of the map view

Returns Promise<Position> ​

getPointInView(location: Position): Promise<Position>; ​

Get the view coordinates based on latitude and longitude

Returns view coordinates [x, y] ​

arguments ​

NameTypeRequiredDescription
locationPosition✓Latitude and longitude coordinates

getCoordinateFromView(location: Position): Promise<Position>; ​

Get the latitude and longitude coordinates based on view coordinates

Returns latitude and longitude coordinates [lng, lat] ​

arguments ​

NameTypeRequiredDescription
locationPosition✓View coordinates [x, y]

setCenter(location: Position); ​

Set the center coordinates

Returns void ​

arguments ​

NameTypeRequiredDescription
locationPosition✓Latitude and longitude coordinates [lng, lat]

setSourceVisibility(visible: boolean, sourceId: string, sourceLayerId: string | null): void; ​

Set the visibility of the source

Returns void ​

arguments ​

NameTypeRequiredDescription
visibleboolean✓Visibility
sourceIdstring✓Source ID
sourceLayerIdstringSource layer ID, if null, all layer visibility is set

zoomTo(step: number, duration?: number): void; ​

Returns void ​

arguments ​

NameTypeRequiredDescription
stepnumber✓Zoom step, for example, 1 represents zoom+1, -1 represents zoom - 1
durationnumberAnimation transition time, default 100 milliseconds

flyTo(center: Position, duration?: number) ​

Set the center coordinates and fly to that location

Returns void ​

arguments ​

NameTypeRequiredDescription
centerPosition✓Latitude and longitude coordinates [lng, lat]
durationnumberFlight time, default 100 milliseconds

getZoom(): Promise<number | undefined>; ​

Get the current map zoom level

Returns zoom level ​

querySourceFeatures(sourceId: string, filter: FilterExpression, layerIDs: string[]): Promise<FeatureCollection> ​

Query the feature collection based on the source

Returns Promise<FeatureCollection> ​

arguments ​

NameTypeRequiredDescription
sourceIdstring✓Source ID
filterFilterExpression✓Filter condition, mapbox style expression
layerIDsstring[]✓Layer ID list

queryRenderFeatures(bbox: BBox, filter: FilterExpression | [], layerIDs?: string[]): Promise<FeatureCollection> ​

Query the feature collection of the visible area based on bbox

Returns Promise<FeatureCollection> ​

arguments ​

NameTypeRequiredDescription
bboxBBox✓[minX, minY, maxX, maxY]
filterFilterExpression✓Filter condition, mapbox style expression
layerIDsstring[]Layer ID list

getVisibleBounds(): Promise<[Position, Position] | undefined>; ​

Get the visible view area bounds [ne, sw]

Returns Promise<[Position, Position] | undefined> ​