获取地图缩放级别不准确
- 当前 Bug 的表现(可附上截图)
获取的缩放级别和自己预先设置的缩放级别不一致
- 预期表现
通过getScale获取自己预先设置的缩放级别
- 复现路径
缩放地图,点击地图的一个maker,放大地图到指定缩放级别,无法正确放大
- 提供一个最简复现 Demo
无
获取的缩放级别和自己预先设置的缩放级别不一致
通过getScale获取自己预先设置的缩放级别
缩放地图,点击地图的一个maker,放大地图到指定缩放级别,无法正确放大
无
你好,测试问题未复现,请提供出现问题的机型和微信版本,以及能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
发现同样的问题:
在真机上 this.mapCtx.getScale 与 设置的比例相同。 在开发工具上小了 2。
比如:
data: {
latitude: app.globalData.userpos.lat,
longitude: app.globalData.userpos.lng,
scale: 14 //这是设置的是 14
},
onShow: function () {
var that = this;
if (!that.mapCtx) {
that.mapCtx = wx.createMapContext(‘pointmap’);
}
},
regionchange: function (e) {
var that = this;
if (e.type==‘end’){
that.mapCtx.getScale({
success: function (sca) {
console.log(sca.scale) // 这里输出 12
}
})
}
}
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) //这里不准确 } }) }, |