收藏
回答

map polyline 路线规划 为什么有时出现两点直线?


地图标记了几个地址。地址之间的路线规划,大多数时候会出现两个地点直线连接

let that =this

console.log('from-to', from, to)

let qqmapsdk = new QQMapWX({ key: that.key});

qqmapsdk.direction({

mode: 'driving', //可选值:'driving'(驾车)、'walking'(步行)、'bicycling'(骑行),不填默认:'driving',可不填

from:  from,

to: to,

success: function (res) {

console.log(res);

var ret = res;

var coors = ret.result.routes[0].polyline, pl = [];

for (var i = 2; i < coors.length; i++) {

coors[i] = coors[i - 2] + coors[i] / 1000000

}

for (var i = 0; i < coors.length; i += 2) {

pl.push({ latitude: coors[i], longitude: coors[i + 1] })

}

that.points = that.points.concat(pl)

that.polyline = [{

points: that.points,

color: '#FF0000DD',

width: 2,

arrowLine:true

}]

console.log('poly',that.polyline)

},


最后一次编辑于  2019-11-18
回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容
问题标签