Skip to main content
Version: 3.x

Taro.createMapContext(mapId, component)

Creates the MapContext object for the map.

Reference

Type​

(mapId: string, component?: Record<string, any>) => MapContext

Parameters​

PropertyTypeDescription
mapIdstringID of the <map/> component
componentRecord<string, any>Under custom components, current component instance "this" operates the <map/> component

Sample Code​

const mapCtx = Taro.createMapContext('myMap')

API Support​

APIWeChat Mini-ProgramH5React Native
Taro.createMapContext✔️