高德地图骑行导航自适应问题?
循环了几个坐标点的骑行路线,默认不能全部自适应展示出来该怎么处理,setFitView自适应无效, 设置缩放比例that.mapViewNew.setZoom(5,false,0)也无效
for(var i=0;i<riderPoint.length;i++){ that.addDeliverymanMarker(that.makePoint(riderPoint[i].coordinate), riderPoint[i].tagName, 1); // 坐标点
if(i<riderPoint.length-1){
//骑行路线
new AMap.Riding({
map: that.mapViewNew,
policy: 1,
hideMarkers: true,
isOutline: false,
autoFitView: true
}).search(that.makePoint(riderPoint[i].coordinate),that.makePoint(riderPoint[i+1].coordinate), function(status, result) {
if (status === 'complete') {
console.log(result)
// that.mapViewNew.setFitView()
} else {
console.log("骑行路线数据查询失败"+result)
}
})
}
}
// that.mapViewNew.setFitView()
回答:
在for
上面定义一个var count=0
在complete
里if(++count == riderPoint.length) setTimeout(()=>map.setFitView())
这样试下。我用高德的用例试了是可以的
以上是 高德地图骑行导航自适应问题? 的全部内容, 来源链接: utcz.com/p/934065.html