本来想看看原生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,
})
}
})
},