- bindregionchange调用后台接口数据动态修改markers死循环
- 当前 Bug 的表现(可附上截图) - 预期表现 - 复现路径 - 提供一个最简复现 Demo 使用map组件,用bindregionchange视图改变去调用后台接口数据动态修改markers,出现重复调用死循环,期望效果是:视图改变动态修改markers不去再触发bindregionchange事件 [代码]onScaleRegion(e) {[代码][代码] [代码][代码]let etype = e.type;[代码][代码] [代码][代码]// 只捕捉移动后的点的信息[代码][代码] [代码][代码]if[代码] [代码](etype === [代码][代码]'end'[代码][代码]) {[代码][代码] [代码][代码]// 获取可视区域的东北和西南的坐标[代码][代码] [代码][代码]this[代码][代码].getRegion()[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码] [代码]getRegion() {[代码][代码] [代码][代码]let that = [代码][代码]this[代码][代码] [代码][代码]this[代码][代码].mapCtx = wx.createMapContext([代码][代码]'map'[代码][代码])[代码][代码] [代码][代码]that.mapCtx.getRegion({[代码][代码] [代码][代码]success: [代码][代码]function[代码][代码](res) {[代码][代码] [代码][代码]let northeast = app.request.qqMapTransBaiduMap(res.northeast.latitude, res.northeast.longitude)[代码][代码] [代码][代码]let southwest = app.request.qqMapTransBaiduMap(res.southwest.latitude, res.southwest.longitude)[代码][代码] [代码][代码]that.mapCtx.getScale({[代码][代码] [代码][代码]success: (scale) => {[代码][代码] [代码][代码]// 调用后台接口,更新markers[代码][代码] [代码][代码]that.getData(northeast, southwest, scale.scale)[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码]getData(northeast, southwest, scale) {[代码][代码] [代码][代码]let that = [代码][代码]this[代码][代码] [代码][代码]let param = {[代码][代码] [代码][代码]beginLat: southwest.lat,[代码][代码] [代码][代码]beginLng: southwest.lng,[代码][代码] [代码][代码]endLat: northeast.lat,[代码][代码] [代码][代码]endLng: northeast.lng,[代码][代码] [代码][代码]level: that.getLevel(scale)[代码][代码] [代码][代码]}[代码][代码] [代码][代码]if[代码] [代码](param.level === [代码][代码]'list'[代码][代码]) {[代码][代码] [代码][代码]param.lat = that.data.latitude[代码][代码] [代码][代码]param.lng = that.data.longitude[代码][代码] [代码][代码]}[代码][代码] [代码][代码]app.request.get([代码][代码]'/xxx'[代码][代码], param).then(data => {[代码][代码] [代码][代码]wx.showToast({[代码][代码] [代码][代码]title: [代码][代码]'test'[代码][代码],[代码][代码] [代码][代码]mask: [代码][代码]true[代码][代码] [代码][代码]})[代码][代码] [代码][代码]let arr = (data.records || []).map((item, index) => {[代码][代码] [代码][代码]let result = app.request.baiduMapTransQQMap(item.lat, item.lng)[代码][代码] [代码][代码]return[代码] [代码]{[代码][代码] [代码][代码]id: index,[代码][代码] [代码][代码]latitude: result.lat,[代码][代码] [代码][代码]longitude: result.lng,[代码][代码] [代码][代码]iconPath: [代码][代码]'../../image/pos.png'[代码][代码],[代码][代码] [代码][代码]width: 30,[代码][代码] [代码][代码]height: 30,[代码][代码] [代码][代码]callout: {[代码][代码] [代码][代码]content: item.storeName,[代码][代码] [代码][代码]padding: 5,[代码][代码] [代码][代码]borderRadius: 5,[代码][代码] [代码][代码]display:[代码][代码]'BYCLICK'[代码][代码],[代码][代码] [代码][代码]textAlign:[代码][代码]'center'[代码][代码],[代码][代码] [代码][代码]bgColor: [代码][代码]'#FFFFFF'[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]markers: arr[代码][代码] [代码][代码]})[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码]
2019-02-28 - 小程序地图组件的bindregionchange属性一直运行
小程序地图组件的bindregionchange属性为什么一直运行[图片] [图片]
2019-03-21 - 小程序地图组件的bindregionchange属性为什么一直运行
- 当前 Bug 的表现(可附上截图) onRegionChanged(e) { // 拖动地图事件 console.log(e,"拖动地图事件") var that = this if (e.type == 'end'){ that.mapCtx.getScale({ success: function (res) { console.log(11111) console.log(res) that.setData({ scale: res.scale + 2 }) } }) } - 预期表现 - 复现路径 - 提供一个最简复现 Demo [图片] [图片] 我要实现的功能是:用户在缩放地图时,我要获取当前的缩放值scale,并且在其他方法中需要调用scale值进行判断
2019-03-14