Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

MapContext mc.createMapContext(String mapId, Object this)

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

参数

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

返回值

类型说明
CameraContextcamera 组件上下文 context

Tips:

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