本來想看看原生api是否有移動到目前定位點,看到有就試着調用看看.發現無效.無奈還是沿用之前的方法
wxml:
<map
id="navi_map"
scale="{{scale}}"
bindcontroltap="controltap"
markers="{{markers}}"
bindmarkertap="markertap"
latitude="{{latitude}}"
longitude="{{longitude}}"
cover-view="40"
show-location
style="width: 100%; height: 100%;"></map>
<image src="******.png" class="imgs" bindtap='tapM'></image>
js:
//目前定位傳回
tapM() {
var that = this;
wx.getLocation({
type: 'gcj02',
isHighAccuracy: true,
success(res) {
const latitude = res.latitude
const longitude = res.longitude
//這裡賦的值 都是給map元件的
that.setData({
scale: 16,
latitude: latitude,
longitude: longitude,
roadFlag: true,
})
}
})
},