map bindregionchange 循环执行
发布于 6 年前 作者 xiena 5133 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)
  • 预期表现

只在地图范围发生改变的时候执行一次

  • 复现路径

<map class=‘mapv’ latitude=’{{latitude}}’ longitude=’{{longitude}}’ scale="{{scale}}" markers="{{markers}}" bindmarkertap=“bindmarkertap” style=‘height:{{maph}}px;’ show-location=“true” bindregionchange=“regionchange” id=“citymap”>

<cover-image src=’/resources/fresh.png’ class=‘mappostion’ bindtap=‘freshopt’ style=‘top:{{maph-126}}px;’></cover-image>

<cover-image src=’/resources/mappostion.png’ class=‘mappostion’ bindtap=‘postionopt’ style=‘top:{{maph-126}}px;’></cover-image>

</map>

//地图范围的改变

regionchange: function(e) {

var that = this;

that.mapCtx = wx.createMapContext(‘citymap’);

// 地图发生变化的时候,获取中间点,也就是用户选择的位置

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

that.mapCtx.getCenterLocation({

success(res) {

console.log(“中心点坐标:”)

console.log(res);

//获取周边的数据

that.GetAroundView(res.latitude, res.longitude);

}

})

}

},

  • 提供一个最简复现 Demo
2 回复

麻烦提供出现问题的机型和微信版本,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

有什么解决方案了吗

回到顶部