MapContext mc.createMapContext(String mapId, Object this)

创建 map 组件上下文 MapContext 对象。建议使用 mc.createSelectorQuery 获取 context 对象。

参数

参数 类型 默认值 必填 说明
mapId String map 组件的 id
this Object 当前页面/自定义组件实例的this,以操作页面/自定义组件内 map 组件

返回值

类型 说明
CameraContext camera 组件上下文 context

Tips:

  • 根据设置的地图类型,MapContext 需要使用对应地图的坐标系
const map = mc.createMapContext('mapId');
map.getCenterLocation({
    success: function(res){
        console.log(res.longitude, res.latitude);
    }
})

results matching ""

    No results matching ""

    results matching ""

      No results matching ""