MapContext instance, which can be obtained by Taro.createMapContext.
MapContext is bound to a <map/> component by id, to operate the corresponding <map/> component.
Methods getCenterLocation Obtain the altitude and longitude of the current map center. The gcj02 coordinate system is returned, which can be used for wx.openLocation()
Reference
( option ? : GetCenterLocationOption ) => void Copy Property Type option GetCenterLocationOption
API Support API WeChat Mini-Program H5 React Native MapContext.getCenterLocation ✔️
getRegion Acquire the scope of the field of view of the current map
Reference
( option ? : GetRegionOption ) => void Copy Property Type option GetRegionOption
API Support API WeChat Mini-Program H5 React Native MapContext.getRegion ✔️
getRotate Acquire the rotation angle of the current map
Reference
( option ? : GetRotateOption ) => void Copy Property Type option GetRotateOption
API Support API WeChat Mini-Program H5 React Native MapContext.getRotate ✔️
getScale Obtains the zoom level of the current map
Reference
( option ? : GetScaleOption ) => void Copy Property Type option GetScaleOption
API Support API WeChat Mini-Program H5 React Native MapContext.getScale ✔️
getSkew Acquire the tilt angle of the current map
Reference
( option ? : GetSkewOption ) => void Copy Property Type option GetSkewOption
API Support API WeChat Mini-Program H5 React Native MapContext.getSkew ✔️
includePoints Zooms in/out the view to show all latitudes and longitudes.
Reference
( option : IncludePointsOption ) => void Copy Property Type option IncludePointsOption
API Support API WeChat Mini-Program H5 React Native MapContext.includePoints ✔️
moveToLocation Moves the map center to the current location. Use with the show-location of the map component.
Reference
( option : MoveToLocationOption ) => void Copy Property Type option MoveToLocationOption
API Support API WeChat Mini-Program H5 React Native MapContext.moveToLocation ✔️
translateMarker Translates marker with animation.
Reference
( option : TranslateMarkerOption ) => void Copy Property Type option TranslateMarkerOption
API Support API WeChat Mini-Program H5 React Native MapContext.translateMarker ✔️
Parameters GetCenterLocationOption Property Type Required Description complete (res: any) => voidNo The callback function used when the API call completed (always executed whether the call succeeds or fails) fail (res: any) => voidNo The callback function for a failed API call success (res: Result) => voidNo The callback function for a successful API call
GetCenterLocationSuccessCallback The callback function for a successful API call
( result : GetCenterLocationSuccessCallbackResult ) => void Copy Property Type result GetCenterLocationSuccessCallbackResult
GetCenterLocationSuccessCallbackResult Property Type Description latitude numberLatitude longitude numberLongitude errMsg stringCall result
GetRegionOption Property Type Required Description complete (res: any) => voidNo The callback function used when the API call completed (always executed whether the call succeeds or fails) fail (res: any) => voidNo The callback function for a failed API call success (res: Result) => voidNo The callback function for a successful API call
GetRegionSuccessCallback The callback function for a successful API call
( result : GetRegionSuccessCallbackResult ) => void Copy Property Type result GetRegionSuccessCallbackResult
GetRegionSuccessCallbackResult Property Type Description northeast numberAltitude and longitude of the Northeast corner southwest numberAltitude and longitude of the Southwest corner errMsg stringCall result
GetRotateOption Property Type Required Description complete (res: any) => voidNo The callback function used when the API call completed (always executed whether the call succeeds or fails) fail (res: any) => voidNo The callback function for a failed API call success (res: Result) => voidNo The callback function for a successful API call
GetRotateSuccessCallback The callback function for a successful API call
( result : GetRotateSuccessCallbackResult ) => void Copy Property Type result GetRotateSuccessCallbackResult
GetRotateSuccessCallbackResult Property Type Description rotate numberThe rotation angle errMsg stringCall result
GetScaleOption Property Type Required Description complete (res: any) => voidNo The callback function used when the API call completed (always executed whether the call succeeds or fails) fail (res: any) => voidNo The callback function for a failed API call success (res: Result) => voidNo The callback function for a successful API call
GetScaleSuccessCallback The callback function for a successful API call
( result : GetScaleSuccessCallbackResult ) => void Copy Property Type result GetScaleSuccessCallbackResult
GetScaleSuccessCallbackResult Property Type Description scale numberScaling value errMsg stringCall result
GetSkewOption Property Type Required Description complete (res: any) => voidNo The callback function used when the API call completed (always executed whether the call succeeds or fails) fail (res: any) => voidNo The callback function for a failed API call success (res: Result) => voidNo The callback function for a successful API call
GetSkewSuccessCallback The callback function for a successful API call
( result : GetSkewSuccessCallbackResult ) => void Copy Property Type result GetSkewSuccessCallbackResult
GetSkewSuccessCallbackResult Property Type Description skew numberSkewing value errMsg stringCall result
IncludePointsOption Property Type Required Description points MapPostion[]Yes List of coordinate points to be displayed in the visible area padding 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. complete (res: any) => voidNo The callback function used when the API call completed (always executed whether the call succeeds or fails) fail (res: any) => voidNo The callback function for a failed API call success (res: Result) => voidNo The callback function for a successful API call
MapPostion List of coordinate points to be displayed in the visual area
Property Type Description latitude numberLatitude longitude numberLongitude
MoveToLocationOption Property Type Required Description latitude numberNo Latitude longitude numberNo Longitude complete (res: any) => voidNo The callback function used when the API call completed (always executed whether the call succeeds or fails) fail (res: any) => voidNo The callback function for a failed API call success (res: Result) => voidNo The callback function for a successful API call
TranslateMarkerOption Property Type Required Description autoRotate booleanYes Specifies whether to automatically rotate the marker when moving destination DestinationOptionYes Specifies the destination to which the marker will move markerId numberYes Specifies the marker rotate numberYes The rotation angle of the marker animationEnd (...args: any[]) => anyNo The callback function used when an animation ends duration numberNo Animation duration, calculated separately for translation and rotation complete (res: any) => voidNo The callback function used when the API call completed (always executed whether the call succeeds or fails) fail (res: any) => voidNo The callback function for a failed API call success (res: Result) => voidNo The callback function for a successful API call
DestinationOption Property Type Description latitude numberLatitude longitude numberLongitude
API Support API WeChat Mini-Program H5 React Native MapContext.getCenterLocation ✔️ MapContext.getRegion ✔️ MapContext.getRotate ✔️ MapContext.getScale ✔️ MapContext.getSkew ✔️ MapContext.includePoints ✔️ MapContext.moveToLocation ✔️ MapContext.translateMarker ✔️