收藏
回答

regionchange 里面大BUG

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug map 客户端 6.7.4 2.4.1



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 个回答

  • 活轨
    活轨
    2019-08-08

    表示ios也会

    2019-08-08
    有用
    回复
  • 是小白啊
    是小白啊
    2018-12-05

    按照教程提供下代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

    2018-12-05
    有用
    回复 2
    • 黎😄
      黎😄
      2018-12-05

      越来越觉得这个代码片段的功能真的很棒,超级棒。

      2018-12-05
      回复
    • 2019-01-24回复黎😄

      Android下会重复调用, iOS下不会,你的问题解决了么

      2019-01-24
      回复
登录 后发表内容