vue使用高德地图地图开发,使用的cdn引入方法,怎么使用步行路径规划api?
修改后
draw_way() {
let location_point = [
{
start: [117.066993, 36.63845],
end: [117.063498, 36.638153]
}
];
// 注册步行规划插件
AMap.plugin("AMap.Walking", () => {
location_point.forEach((item, index) => {
let startPoint = location_point[index].start;
let endPoint = location_point[index].end;
this.walking = new AMap.Walking({
map: this.map,
panel: "panel" + index
});
this.walking.search(startPoint, endPoint, (status, result) => {
if (status === "complete") {
let routes = result.routes;
let point_path = routes[0].steps;
point_path.forEach((item, index) => {
let polyline = new AMap.Polyline({
map: this.map,
path: point_path[index].path,
strokeColor: "red",
strokeOpacity: 0.7,
strokeWeight: 4
});
});
} else {
console.error(result);
}
});
});
});
},
实现效果
回复
1个回答
适合作为回答的
- 经过验证的有效解决办法
- 自己的经验指引,对解决问题有帮助
- 遵循 Markdown 语法排版,代码语义正确
不该作为回答的
- 询问内容细节或回复楼层
- 与题目无关的内容
- “赞”“顶”“同问”“看手册”“解决了没”等毫无意义的内容