小程序map地图通过 MapContext.includePoints 重新设置地图视野,在complete或者success回调中设置地图中心点坐标不生效;
如下:
var mapctx = wx.createMapContext('mymap', this);
mapctx.includePoints({
points: includepoints,
padding: [60],
success: (res) => {
},
fail(data) {
console.log('includePoints失败:', data)
},
complete(data) {
mapctx.getCenterLocation({
success(res) {
console.log('缩放后地图中心:', res)
var longitude = that.longitude
var latitude = that.latitude
that.setData({
'longitude': longitude,
'latitude': latitude,
})
},
complete() {
var longitude = that.longitude
var latitude = that.latitude
that.setData({
'longitude': longitude,
'latitude': latitude,
})
}
})
}
})