1、地图无操作下出现缓慢的自行移动:
2,问题原因: @regionchange 方法不断被触发,且不移动时获取的维度坐标总比我们当前的 -1
3,解决方法:通过限制静态时触发的偏移量,不触发对应的区域接口,各位的数据偏移量和方向可能各有不同,需要根据具体的问题进行设置。
4,具体代码:
//滑动了地图 changeMap(e) { console.log('滑动'); const that = this; that.mapContext = uni.createMapContext("map", that); console.log('that.mapContext', that.mapContext); that.mapContext.getCenterLocation({ type: 'gcj02', success: (res) => { // 对静态移动标点做限制防止偏移 if(that.latitude - res.latitude < 0.000005 && that.list.length > 0) { return } // 更新地图中心坐标 that.latitude = res.latitude; that.longitude = res.longitude; console.log( 'that.latitude', that.latitude) const latitude = that.latitude; const longitude = that.longitude;