map实时定位问题
发布于 7 年前 作者 jiewang 755 次浏览 来自 问答

每次地图的定位,当我在屏幕上移动地图的时候,由于实时执行UpdateLocation()方法,导致页面一直会返回到当前定位的地方;此问题如何解决呢;

updateLocation() 方法:

updateLocation: function(){

var that=this;

wx.getLocation({

type: ‘gcj02’,

success: function (res) {

console.log(res)

latitude = res.latitude

longitude = res.longitude

that.setData({

latitude: latitude,

longitude: longitude,

})

wx.setStorageSync(‘latitude’, latitude);

wx.setStorageSync(‘longitude’, longitude);

}

});

},

2 回复

我现在在用地图的时候,发现移动的时候地图的定位并不移动,然后我就通过手动实时刷新去调用getLocation ,现在移动是可以了 ,但是当我们把地图的位置挪到离当前定位的位置很远的时候,会直接自己调到中心定位的地方

第一次获取的位置设为中心经纬度的同时,作为标注点的经纬度,后续更新的位置经纬度不要去改变中心点的经纬度。

回到顶部