Skip to content

Map

createMapContext

createMapContext(string mapId)

create map context MapContext Object. Recommended use wx.createSelectorQuery Obtain context Object

parameter

parameter string mapId map Component id

Return value

MapContext

MapContext

MapContext.addArc

Add arc, pass point and Angle must set one

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
idnumberyesArc id
startObjectyesStarting point
endObjectyesEnd point
passObjectnoPassing point
anglenumber0noIncluded Angle
widthnumber5noLine width
colornumber#000000noLine color
successfunctionnoThe interface calls a successful callback function
failfunctionnoInterface to call a failed callback function
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.start Structure

attributetypeDefault valuesRequiredIntroductions
longitudenumberyesLongitude
latitudenumbeyesLatitude

object.end Structure

attributetypeDefault valuesRequiredIntroductions
longitudenumberyesLongitude
latitudenumbeyesLatitude

bject.pass Structure

attributetypeDefault valuesRequiredIntroductions
longitudenumberyesLongitude
latitudenumbeyesLatitude

MapContext.addCustomLayer

Add personalized layers.

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
layerIdstringyesPersonalize Layer ID
successfunctionnoThe interface calls a successful callback function
failfunctionnoInterface to call a failed callback function
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

MapContext.addGroundOverlay

Create a custom image layer and the image will be scaled as the map is scaled.

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
idStringyesPicture layer id
srcStringyesPicture path, support network picture, temporary path, code package path
boundsObjectyesLatitude and longitude coverage of the picture
visibleBooleantruenoWhether visible
zIndexNumber1noLayer Drawing Order
opacityNumber1noLayer transparency
successfunctionnoThe interface calls a successful callback function
failfunctionnoInterface to call a failed callback function
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.bounds Structure

attributetypeDefault valuesRequiredIntroductions
southwestObjectyesSouth-west latitude and longitude
northeastObjectyesNortheast longitude and latitude

bounds.southwest Structure

attributetypeDefault valuesRequiredIntroductions
longitudenumberyesLongitude
latitudenumberyesLatitude

bounds.northeast Structure

attributetypeDefault valuesRequiredIntroductions
longitudenumberyesLongitude
latitudenumberyesLatitude

MapContext.addMarkers

Add to marker


Support :
System map (iOS only)


Amap
iOS: ✅ Android: ✅ IDE: ✅


Baidu map (iOS, Android only)
iOS: ✅ Android: ✅


Google Maps (Android only)

parameter

attributetypeDefault valuesRequiredIntroductionsOther
markersArrayyesSame afferent map Component marker attribute
clearbooleanfalsenoDo you want to clear all the maps first? markerNot supported on iOS
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

MapContext.addVisualLayer

Not supported

MapContext.fromScreenLocation

Gets the latitude and longitude corresponding to the point on the screen. The coordinate origin is the upper-left corner of the map


Support :
System map (iOS only)


Amap
iOS: ✅ Android: ✅ IDE: ✅


Baidu map (iOS, Android only)
iOS: ✅ Android: ✅


Google Maps (Android only)

parameter

attributetypeDefault valuesRequiredIntroductionsOther
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

MapContext.getCenterLocation

Obtain the altitude and longitude of the current map center. The gcj02 coordinate system is returned, which can be used for ft.openLocation()


Support :
System map (iOS only)


Amap
iOS: ✅ Android: ✅ IDE: ✅


Baidu map (iOS, Android only)
iOS: ✅ Android: ✅


Google Maps (Android only)

parameter

attributetypeDefault valuesRequiredIntroductionsOther
iconPathstringnoIcon paths, network paths, local paths, package paths supportediOS not supported
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

MapContext.getRegion

Acquire the scope of the field of view of the current map


Support :
System map (iOS only)


Amap
iOS: ✅ Android: ✅ IDE: ✅


Baidu map (iOS, Android only)
iOS: ✅ Android: ✅


Google Maps (Android only)

parameter

attributetypeDefault valuesRequiredIntroductionsOther
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

MapContext.getRotate

Gets the rotation angle of the current map


Support :
System map (iOS only)


Amap
iOS: ✅ Android: ✅ IDE: ✅


Baidu map (iOS, Android only)
iOS: ✅ Android: ✅


Google Maps (Android only)

parameter

attributetypeDefault valuesRequiredIntroductionsOther
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

MapContext.getScale

Acquire the degree of scaling of the current map


Support :
System map (iOS only)


Amap
iOS: ✅ Android: ✅ IDE: ✅


Baidu map (iOS, Android only)
iOS: ✅ Android: ✅


Google Maps (Android only)

parameter

attributetypeDefault valuesRequiredIntroductionsOther
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

MapContext.getSkew

Gets the tilt angle of the current map


Support :
System map (iOS only)


Amap
iOS: ✅ Android: ✅ IDE: ✅


Baidu map (iOS, Android only)
iOS: ✅ Android: ✅


Google Maps (Android only)

parameter

attributetypeDefault valuesRequiredIntroductionsOther
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

MapContext.includePoints

Scale the field of view to display all latitude and longitude degrees


Support :
System map (iOS only)


Amap
iOS: ✅ Android: ✅ IDE: ❌


Baidu map (iOS, Android only)
iOS: ✅ Android: ✅


Google Maps (Android only)

parameter

attributetypeDefault valuesRequiredIntroductionsOther
pointsArray.Object>yesList of coordinate points to be displayed in the visible area
paddingArray.number>noDistance between the edge of the rectangle formed by coordinate points and the edge of the map (in pixel). The format is [top, right, bottom, left]. Only the first item of the array can be identified on Android. The padding is consistent for top, bottom, left, and right. Padding parameters are currently not supported on developer tools.
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

MapContext.initMarkerCluster

Initializes the configuration of the point aggregation, the default configuration when not invoked


Support :
System map (iOS only)


Amap
iOS:❌ Android:✅ Not supported enableDefaultStyle IDE:❌


Baidu map (iOS, Android only)
iOS:❌ Android:✅ enableDefaultStyle is not supported


Google Maps (Android only)
✅ enableDefaultStyle is not supported

parameter

attributetypeDefault valuesRequiredIntroductionsOther
enableDefaultStylebooleantruenoEnable default aggregate styles
zoomOnClickbooleantruenoWhether to implement aggregation separation when clicking on the already aggregated marker
gridSizenumber60noAggregation algorithm can be aggregated distance, that is, distance less than this value points will be aggregated together, in pixels
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

MapContext.moveAlong

Move along a specified path markerFor track playback and other scenarios. A callback event is triggered when the animation is complete. If animation is in progress, the marker Call again moveAlong Method, the previous animation will be interrupted


Support :
System map (iOS only)


Amap
iOS: ✅ Android: ✅ IDE: ✅


Baidu map (iOS, Android only)
iOS: ✅ Android: ✅


Google Maps (Android only)

parameter

attributetypeDefault valuesRequiredIntroductionsOther
markerIdnumberyesDesignation marker
pathArrayyesCoordinate string of moving path, coordinate point format {longitude, latitude}
autoRotatebooleantrueno初始值 marker Rotation angle
durationnumberyes平滑移动的时间
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

MapContext.moveToLocation

Move the center of the map to the current set position. Needs to be used in coordination with the map component's show-location


Support :
System map (iOS only)


Amap
iOS: ✅ Android: ✅ IDE: ✅


Baidu map (iOS, Android only)
iOS: ✅ Android: ✅


Google Maps (Android only)

parameter

attributetypeDefault valuesRequiredIntroductionsOther
longitudenumbernoLongitude
latitudenumbernoLatitude
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

MapContext.on

Monitor map events:'markerClusterCreate'Triggered when scaling or dragging causes a new aggregate cluster to be generated, only the newly created aggregate cluster information is returned; 'markerClusterClick'Click events for the aggregate cluster


Support :
System map (iOS only)


Amap
iOS:❌ Android:✅ Not supported markerClusterCreate IDE:❌


Baidu map (iOS, Android only)
markerClusterCreate is not supported on iOS:❌ Android:✅


Google Maps (Android only)
✅ does not support markerClusterCreate

sample code

javascript
  MapContext.on('markerClusterCreate', (res) => {})
  MapContext.on('markerClusterClick', (res) => {})

MapContext.openMapApp

Pull up the map app and select navigation


Support :
System map (iOS only)


Amap
iOS: ✅ Android: ✅ IDE: ❌


Baidu map (iOS, Android only)
iOS: ✅ Android: ✅


Google Maps (Android only)

parameter

attributetypeDefault valuesRequiredIntroductionsOther
longitudeNumberyesDestination longitude
latitudeNumberyesDestination latitude
destinationStringyesDestination name
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

MapContext.removeCustomLayer

Remove the personalization layer.

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
layerIdstringyesPersonalize Layer ID
successfunctionnoThe interface calls a successful callback function
failfunctionnoInterface to call a failed callback function
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

MapContext.removeGroundOverlay

Remove the custom image layer.

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
idstringyesPicture layer id
successfunctionnoThe interface calls a successful callback function
failfunctionnoInterface to call a failed callback function
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

MapContext.removeMarkers

to remove marker


Support :
System map (iOS only)


Amap
iOS: ✅ Android: ✅ IDE: ✅


Baidu map (iOS, Android only)
iOS: ✅ Android: ✅


Google Maps (Android only)

parameter

attributetypeDefault valuesRequiredIntroductions
markerIdsArrayyesmarker of id Gather.
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

MapContext.setBoundary

Limit the map display area

parameter

Object object

| attribute | type | Default values | Required | Introductions | | --- | --- | --- | --- | --- | --- | | southwest | Object | | yes | South-west latitude and longitude | | northeast | Object | | yes | Northeast longitude and latitude | | success | function | | no | Interface calls the successful callback function | | fail | function | | no | Interface calls failed callback functions | | complete | function | | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |

bounds.southwest Structure

attributetypeDefault valuesRequiredIntroductions
longitudenumberyesLongitude
latitudenumberyesLatitude

bounds.northeast Structure

attributetypeDefault valuesRequiredIntroductions
longitudenumberyesLongitude
latitudenumberyesLatitude

MapContext.removeVisualLayer

Not supported。

MapContext.setCenterOffset

Set Map Center Point Offset, Back Down for Growth, Screen Scale Range(0.250.75)The default offset is[0.5, 0.5]


Support :
System map (iOS only)


Amap
iOS: ✅ Android: ✅ IDE: ❌


Baidu map (iOS, Android only)
iOS: ❌ Android: ❌


Google Maps (Android only)

parameter

attributetypeDefault valuesRequiredIntroductionsOther
offsetArray.number>yesOffset, two-bit array
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

MapContext.setLocMarkerIcon

Set anchor icon, support network path, local path, code package path


Support :
System map (iOS only)


Amap
iOS: ✅ Android: ✅ IDE: ❌


Baidu map (iOS, Android only)
iOS: ✅ Android: ✅


Google Maps (Android only)

parameter

attributetypeDefault valuesRequiredIntroductionsOther
iconPathstringnoIcon path, support network path, local path, code package path
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

MapContext.toScreenLocation

Get the screen coordinates corresponding to latitude and longitude. The origin of the coordinates is the upper left corner of the map


Support :
System map (iOS only)


Amap
iOS: ✅ Android: ✅ IDE: ❌


Baidu map (iOS, Android only)
iOS: ✅ Android: ✅


Google Maps (Android only)

parameter

attributetypeDefault valuesRequiredIntroductionsOther
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

MapContext.translateMarker

Translation market, animated


Support :
System map (iOS only)


Amap
iOS: ✅ Android: ✅ IDE: ✅


Baidu map (iOS, Android only)
iOS: ✅ Android: ✅


Google Maps (Android only)

parameter

attributetypeDefault valuesRequiredIntroductionsOther
markerIdNumberyesDesignation marker
destinationObjectyesDestination point the specified marker moved to
autoRotatebooleanyesWhether the marker automatically rotates while moving
rotateNumberyesRotating angle of the markeriOS不支持
moveWithRotatebooleanfalsenoTranslation and rotation at the same timeiOS不支持
IDE不支持
durationNumber1000noAnimation duration. Translation and rotation are calculated separately
animationEndfunctionnoThe callback function returned when the animation ends
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

MapContext.updateGroundOverlay

Update custom image layers.

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
idStringyesPicture layer id
srcStringyesPicture path, support network picture, temporary path, code package path
boundsObjectyesLatitude and longitude coverage of the picture
visibleBooleantruenoWhether visible
zIndexNumber1noLayer Drawing Order
opacityNumber1noLayer transparency
successfunctionnoThe interface calls a successful callback function
failfunctionnoInterface to call a failed callback function
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.bounds Structure

attributetypeDefault valuesRequiredIntroductions
southwestObjectyesSouth-west latitude and longitude
northeastObjectyesNortheast longitude and latitude

bounds.southwest Structure

attributetypeDefault valuesRequiredIntroductions
longitudenumberyesLongitude
latitudenumberyesLatitude

bounds.northeast Structure

attributetypeDefault valuesRequiredIntroductions
longitudenumberyesLongitude
latitudenumberyesLatitude