修改后
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);
}
});
});
});
},
实现效果
看文档
https://lbs.amap.com/api/webservice/guide/api/direction
https://lbs.amap.com/api/webservice/guide/api/newroute