html52.com
我爱小程序-开发者交流社区

获取地图缩放级别不准确

问题模块 框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
API和组件 小程序 Bug wx.createMapContext.getScale() 客户端 6.7.1 2.2.4

- 当前 Bug 的表现(可附上截图)


获取的缩放级别和自己预先设置的缩放级别不一致


- 预期表现


通过getScale获取自己预先设置的缩放级别


- 复现路径


缩放地图,点击地图的一个maker,放大地图到指定缩放级别,无法正确放大


- 提供一个最简复现 Demo


网友回复

夏:
onMarkerClick: function(e) {
    var markerId = e.markerId
    var ids = markerId.split("-")
    if (flagMarkerC == ids[0]) { //点击了城市的Marker
      var markerInfo = JSON.parse(ids[1])
      this.setData({
        latitude: markerInfo.citylat,
        longitude: markerInfo.citylng,
      })
      this.mapCtx.moveToLocation()
      this.setData({
        scale: zoomShowAreaJuHeValue - 1
      })
    } else if (flagMarkerP == ids[0]) { //点击了区域的Marker
      var markerInfo = JSON.parse(ids[1])
      this.setData({
        latitude: markerInfo.lat,
        longitude: markerInfo.lng,
      })
      this.mapCtx.moveToLocation()
      this.setData({
        scale: this.initscaleSize
      }, (result) => {
        console.log(result)
      })
    }
  },
 
  mapChange: function() {
    var that = this
 
    this.mapCtx.getScale({ //获取地图缩放级别
      success: function(res) {
        var scale = res.scale
        console.log("scale---》》》" + scale)   //这里不准确
      }
    })
  },


nickname:

你好,测试问题未复现,请提供出现问题的机型和微信版本,以及能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付