map polyline 路线规划 为什么有时出现两点直线?
发布于 8 年前 作者 weimo 3497 次浏览 来自 官方Issues

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

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)

},

1 回复

你好,麻烦具体描述问题流程,提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

回到顶部