MapContext.getCenterLocation
解释:获取当前地图中心的经纬度,返回的是 gcj02 坐标系,可以用于 swan.openLocation。
方法参数
Object object
object参数说明
success返回参数说明
示例
在开发者工具中预览效果
扫码体验
请使用百度APP扫码
图片示例
代码示例
-
Page({ data: { }, onReady() { this.mapContext = swan.createMapContext('myMap'); }, getCenterLocation: function () { this.mapContext.getCenterLocation({ success: function (res) { swan.showModal({ title: '位置信息', content: (res.longitude).toFixed(2) + '/' + (res.latitude).toFixed(2) }); console.log("经度", res.longitude); console.log("纬度", res.latitude); } }) }});
