所以,基本上我用谷歌Map使用方向创建了一条路线。我如何解码这个overview_polyline?
function calcRoute() {
var waypts = [
{ location: "Sao José dos campos,SP", stopover: true },
];
directionsService
.route({
origin: "Rio de Janeiro, RJ",
destination: "São paulo, SP",
waypoints: waypts,
travelMode: google.maps.TravelMode.DRIVING,
provideRouteAlternatives: true,
})
.then((response) => {
console.log({ response });
directionsRenderer.setDirections(response);
var rotaFeita = response.routes[0].overview_polyline; // I NEED TO DECODE THIS "rotaFeita"
google.maps.geometry.decodePath(rotaFeita)
console.log(rotaFeita);
})
.catch((err) => {
console.log({ err });
});
}
1条答案
按热度按时间rmbxnbpk1#
用你的密码我得到一条信息:
TypeError: google.maps.geometry.decodePath is not a function
..decodePath
的正确路径为:google.maps.geometry.encoding.decodePath
要使用该调用的结果创建
Polyline
,请执行以下操作:proof of concept fiddle
程式码片段:
第一个