title: Taro.createMapContext(mapId, component)

sidebar_label: createMapContext

Creates the MapContext object for the map.

Reference

Type

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

Parameters

Property Type Description
mapId string ID of the <map/> component
component Record<string, any> Under custom components, current component instance “this” operates the <map/> component

Sample Code

  1. const mapCtx = Taro.createMapContext('myMap')

API Support

API WeChat Mini-Program H5 React Native
Taro.createMapContext ✔️