<!--wxml-->
<map bindregionchange="regionchange" ></map>
<!--js-->
regionchange(e) {
const that = this
if (e.causedBy == "drag") {
this.mapCtx.getCenterLocation({
success: function (res) {
that.setData({
latitude: res.latitude,
longitude: res.longitude
})
}
})
};
if (e.causedBy == "scale") {
this.mapCtx.getScale({
success(res) {
const n = parseInt(res.scale) 拿到动态缩放度
if (n == that.data.scale) return
if (n > 15) return
if (n < 8) return
不同缩放程序进行做不同的事
switch (n) {
case 11:
break
case 14:
break
case 10:
break
case 12:
break
// case 13:
// break
// case 14:
// break
}
}
})
}
地图可能渲染bug 可用wx:if对map处理重新渲染,但会影响性能,自己酌情考虑使用。。