在可拖动路由期间,我们是否可以沿路由方式获取纬度和经度值
如果有,请给我一个链接或解决方案
感谢您的帮助
答案 0 :(得分:0)
Example of how to iterate through the coordinates in a dragged route(查看getPolylineXml函数)
答案 1 :(得分:0)
请参阅我的示例以获取路线中所有点的LatLng
directionsRenderer.addListener("directions_changed", function() {
var lat = [];
var lng = [];
result = directionsRenderer.getDirections()
var myroute = result.routes[0];
for (var i = 0; i < myroute.legs.length; i++)
{
//console.log(myroute.legs[i].start_location.lat())
lat[i] = myroute.legs[i].start_location.lat();
lng[i] = myroute.legs[i].start_location.lng();
}
i=myroute.legs.length-1;
lat[i+1] = myroute.legs[i].end_location.lat();
lng[i+1] = myroute.legs[i].end_location.lng();
console.log(lat)
console.log(lng)
});