MapContext.moveToLocation
解释:将地图中心移动到当前定位点,需要配合 map 组件的 show-location 使用 。
方法参数
无
示例
在开发者工具中预览效果
扫码体验
请使用百度APP扫码
图片示例
代码示例
-
<view class="wrap"> <map id="myMap" longitude="{{longitude}}" latitude="{{latitude}}" style="width: 100%" show-location > </map> <button type="primary" bindtap="moveToLocation">移动到当前定位点</button></view>
-
Page({data: {latitude: 40.048828,longitude: 116.280412,},onReady() {this.mapContext = swan.createMapContext('myMap');},moveToLocation: function () {this.mapContext.moveToLocation();}});
