小程序
小游戏
企业微信
微信支付
扫描小程序码分享
1 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
var QQMapWX = require('./qqmap-wx-jssdk');
let qqmapsdk = new QQMapWX({
key: 'XXXX-XXXX-XXXX-XXXX-XXXX-XXXX'
});
let direction = (from, to) => {
return new Promise((resolve, reject) => {
qqmapsdk.direction({
from,
to,
success: res => {
let ret = res;
let coors = ret.result.routes[0].polyline,
pl = [];
//坐标解压(返回的点串坐标,通过前向差分进行压缩)
let kr = 1000000;
for (let i = 2; i < coors.length; i++) {
coors[i] = Number(coors[i - 2]) + Number(coors[i]) / kr;
}
//将解压后的坐标放入点串数组pl中
for (let i = 0; i < coors.length; i += 2) {
pl.push({
latitude: coors[i],
longitude: coors[i + 1]
})
resolve(pl)
},
fail: res => {
reject("规划路径错误:", res)
规划路径
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
var QQMapWX = require('./qqmap-wx-jssdk');
let qqmapsdk = new QQMapWX({
key: 'XXXX-XXXX-XXXX-XXXX-XXXX-XXXX'
});
let direction = (from, to) => {
return new Promise((resolve, reject) => {
qqmapsdk.direction({
from,
to,
success: res => {
let ret = res;
let coors = ret.result.routes[0].polyline,
pl = [];
//坐标解压(返回的点串坐标,通过前向差分进行压缩)
let kr = 1000000;
for (let i = 2; i < coors.length; i++) {
coors[i] = Number(coors[i - 2]) + Number(coors[i]) / kr;
}
//将解压后的坐标放入点串数组pl中
for (let i = 0; i < coors.length; i += 2) {
pl.push({
latitude: coors[i],
longitude: coors[i + 1]
})
}
resolve(pl)
},
fail: res => {
reject("规划路径错误:", res)
}
})
})
}
规划路径