在map地图中定义@regionchange
<map class="myMap" id="map" ref="map" :scale="scale"
:markers="markers"
:longitude="longitude" :latitude="latitude"
@regionchange="regionchange"
>
用户滑动触发函数,并设置滑动结束触发获取定位
regionchange(event) {
console.log('regionchange', event)
if(event.detail.type =='end'){
this.getCenterLanLat()
}
},
获取定位
/ 获取当前地图中心的经纬度
getCenterLanLat() {
uni.createMapContext("map", this).getCenterLocation({
type: 'gcj02',
success: (res) => {
console.log("当前地图中心的经纬度",res)
//其他逻辑
},
fail:(err)=>{
}
})
},