Appearance
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
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
id | number | yes | Arc id | |
start | Object | yes | Starting point | |
end | Object | yes | End point | |
pass | Object | no | Passing point | |
angle | number | 0 | no | Included Angle |
width | number | 5 | no | Line width |
color | number | #000000 | no | Line color |
success | function | no | The interface calls a successful callback function | |
fail | function | no | Interface to call a failed callback function | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.start Structure
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
longitude | number | yes | Longitude | |
latitude | numbe | yes | Latitude |
object.end Structure
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
longitude | number | yes | Longitude | |
latitude | numbe | yes | Latitude |
bject.pass Structure
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
longitude | number | yes | Longitude | |
latitude | numbe | yes | Latitude |
MapContext.addCustomLayer
Add personalized layers.
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
layerId | string | yes | Personalize Layer ID | |
success | function | no | The interface calls a successful callback function | |
fail | function | no | Interface to call a failed callback function | |
complete | function | no | Callback 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
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
id | String | yes | Picture layer id | |
src | String | yes | Picture path, support network picture, temporary path, code package path | |
bounds | Object | yes | Latitude and longitude coverage of the picture | |
visible | Boolean | true | no | Whether visible |
zIndex | Number | 1 | no | Layer Drawing Order |
opacity | Number | 1 | no | Layer transparency |
success | function | no | The interface calls a successful callback function | |
fail | function | no | Interface to call a failed callback function | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.bounds Structure
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
southwest | Object | yes | South-west latitude and longitude | |
northeast | Object | yes | Northeast longitude and latitude |
bounds.southwest Structure
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
longitude | number | yes | Longitude | |
latitude | number | yes | Latitude |
bounds.northeast Structure
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
longitude | number | yes | Longitude | |
latitude | number | yes | Latitude |
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
attribute | type | Default values | Required | Introductions | Other |
---|---|---|---|---|---|
markers | Array | yes | Same afferent map Component marker attribute | ||
clear | boolean | false | no | Do you want to clear all the maps first? marker | Not supported on iOS |
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) |
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
attribute | type | Default values | Required | Introductions | Other |
---|---|---|---|---|---|
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) |
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
attribute | type | Default values | Required | Introductions | Other |
---|---|---|---|---|---|
iconPath | string | no | Icon paths, network paths, local paths, package paths supported | iOS not supported | |
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) |
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
attribute | type | Default values | Required | Introductions | Other |
---|---|---|---|---|---|
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) |
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
attribute | type | Default values | Required | Introductions | Other |
---|---|---|---|---|---|
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) |
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
attribute | type | Default values | Required | Introductions | Other |
---|---|---|---|---|---|
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) |
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
attribute | type | Default values | Required | Introductions | Other |
---|---|---|---|---|---|
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) |
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
attribute | type | Default values | Required | Introductions | Other |
---|---|---|---|---|---|
points | Array.Object> | yes | List of coordinate points to be displayed in the visible area | ||
padding | Array.number> | no | Distance 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. | ||
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) |
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
attribute | type | Default values | Required | Introductions | Other |
---|---|---|---|---|---|
enableDefaultStyle | boolean | true | no | Enable default aggregate styles | |
zoomOnClick | boolean | true | no | Whether to implement aggregation separation when clicking on the already aggregated marker | |
gridSize | number | 60 | no | Aggregation algorithm can be aggregated distance, that is, distance less than this value points will be aggregated together, in pixels | |
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) |
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
attribute | type | Default values | Required | Introductions | Other |
---|---|---|---|---|---|
markerId | number | yes | Designation marker | ||
path | Array | yes | Coordinate string of moving path, coordinate point format {longitude, latitude} | ||
autoRotate | boolean | true | no | 初始值 marker Rotation angle | |
duration | number | yes | 平滑移动的时间 | ||
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) |
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
attribute | type | Default values | Required | Introductions | Other |
---|---|---|---|---|---|
longitude | number | no | Longitude | ||
latitude | number | no | 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) |
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
attribute | type | Default values | Required | Introductions | Other |
---|---|---|---|---|---|
longitude | Number | yes | Destination longitude | ||
latitude | Number | yes | Destination latitude | ||
destination | String | yes | Destination name | ||
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) |
MapContext.removeCustomLayer
Remove the personalization layer.
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
layerId | string | yes | Personalize Layer ID | |
success | function | no | The interface calls a successful callback function | |
fail | function | no | Interface to call a failed callback function | |
complete | function | no | Callback 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
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
id | string | yes | Picture layer id | |
success | function | no | The interface calls a successful callback function | |
fail | function | no | Interface to call a failed callback function | |
complete | function | no | Callback 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
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
markerIds | Array | yes | marker of id Gather. | |
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) |
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
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
longitude | number | yes | Longitude | |
latitude | number | yes | Latitude |
bounds.northeast Structure
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
longitude | number | yes | Longitude | |
latitude | number | yes | Latitude |
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
attribute | type | Default values | Required | Introductions | Other |
---|---|---|---|---|---|
offset | Array.number> | yes | Offset, two-bit array | ||
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) |
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
attribute | type | Default values | Required | Introductions | Other |
---|---|---|---|---|---|
iconPath | string | no | Icon path, support network path, local path, code package path | ||
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) |
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
attribute | type | Default values | Required | Introductions | Other |
---|---|---|---|---|---|
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) |
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
attribute | type | Default values | Required | Introductions | Other |
---|---|---|---|---|---|
markerId | Number | yes | Designation marker | ||
destination | Object | yes | Destination point the specified marker moved to | ||
autoRotate | boolean | yes | Whether the marker automatically rotates while moving | ||
rotate | Number | yes | Rotating angle of the marker | iOS不支持 | |
moveWithRotate | boolean | false | no | Translation and rotation at the same time | iOS不支持 IDE不支持 |
duration | Number | 1000 | no | Animation duration. Translation and rotation are calculated separately | |
animationEnd | function | no | The callback function returned when the animation ends | ||
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) |
MapContext.updateGroundOverlay
Update custom image layers.
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
id | String | yes | Picture layer id | |
src | String | yes | Picture path, support network picture, temporary path, code package path | |
bounds | Object | yes | Latitude and longitude coverage of the picture | |
visible | Boolean | true | no | Whether visible |
zIndex | Number | 1 | no | Layer Drawing Order |
opacity | Number | 1 | no | Layer transparency |
success | function | no | The interface calls a successful callback function | |
fail | function | no | Interface to call a failed callback function | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.bounds Structure
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
southwest | Object | yes | South-west latitude and longitude | |
northeast | Object | yes | Northeast longitude and latitude |
bounds.southwest Structure
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
longitude | number | yes | Longitude | |
latitude | number | yes | Latitude |
bounds.northeast Structure
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
longitude | number | yes | Longitude | |
latitude | number | yes | Latitude |