regionchange 里面大BUG

发布于 6 年前作者 leizhao7726 次浏览最后编辑 6 年前来自 ask

regionchange(e) {

    if (e.type == ‘end’) {

    console.log(“地图移动”)

    this.getLngLat()

    }

},

getLngLat: function () {

function sortNumber(a, b){

return a - b

}

var that = this;

this.mapCtx = wx.createMapContext(“myMap”);

this.mapCtx.getCenterLocation({

    success: function (res) {

    console.log(res);

    that.setData({

    centerLat: res.latitude,

    centerLog: res.longitude,

    })

console.log(“会重复调用”)

if (res.latitude == that.data.mapLat){

console.log(“相同”)

}else{

var setNum;

var grr = [];

for (var p = 0; p < that.data.circles.length; p++) {

var kun = p;

grr.push(calculateDistance(that.data.circles[kun].latitude, that.data.circles[kun].longitude, res.latitude, res.longitude))

}

grr.sort(sortNumber);

for (var p = 0; p < that.data.circles.length; p++) {

var kun = p;

if (grr[0] == calculateDistance(that.data.circles[kun].latitude, that.data.circles[kun].longitude, res.latitude, res.longitude)) {

console.log(“设置新的地图”)

setNum = kun;            }

}

that.setData({

mapLat: that.data.circles[setNum].latitude,

mapLong: that.data.circles[setNum].longitude

})

}

}

})

},

2 回复
linxiuying
linxiuying2 楼5 年前

表示ios也会