在使用map组件时,要实现用户手动缩放地图后,想一键调整到某个scale值(比如scale=3),这个要怎样实现?
btw,setdata scale没有反应。
吧你代码贴出来,我试了一下可以的。
<map id="myMap" scale="{{mapScale}}"></map>
data:{ mapScale:14,}
setMapScale: function (e) {
this.setData({
mapScale:25,
});
},
show_all(e){
var t =this
console.log('show_all')
t.setData({scale:3})
},
<map
id="map"
subkey="HPRBZ-36ZCU-5P5VW-BFVPM-7YX3V-HMBWT"
layer-style="2"
longitude="{{my_longitude}}"
latitude="{{my_latitude}}"
scale="{{scale}}"
markers="{{markers}}"
enable-poi="{{false}}"
show-location
style="width: 100%; height: 60vh;">
</map>
<cover-view bindtap="show_all" class="margin-left text-white" style="width: 20%;display:flex;flex-direction:row;justify-content:center;align-items:center;">
<cover-view style="border: 1rpx white solid;border-radius: 20%;"> <cover-view style="margin: 5rpx;">全景</cover-view> </cover-view>
</cover-view>