Cde*_*eez 13 google-maps google-maps-api-3 map-directions
我的应用程序允许用户在地图上选择两个点,并使用Google地图Apiv3的路线服务查找它们之间的路线.然后必须将沿此路线的坐标保存到数据库中.我可以成功编写所有代码来完成此任务.但是我被遗漏了一个问题.
我知道在StackOverflow中还有其他一些问题 - 一,二,同时,但我认为他们或我在这里错过了一些东西.
示例代码:
function getCoordinates(result) {
var currentRouteArray = result.routes[0]; //Returns a complex object containing the results of the current route
var currentRoute = currentRouteArray.overview_path; //Returns a simplified version of all the coordinates on the path
obj_newPolyline = new google.maps.Polyline({ map: map }); //a polyline just to verify my code is fetching the coordinates
var path = obj_newPolyline.getPath();
for (var x = 0; x < currentRoute.length; x++) {
var pos = new google.maps.LatLng(currentRoute[x].kb, currentRoute[x].lb)
latArray[x] = currentRoute[x].kb; //Returns the latitude
lngArray[x] = currentRoute[x].lb; //Returns the longitude
path.push(pos);
}
}
Run Code Online (Sandbox Code Playgroud)
上面的代码工作正常,只是看起来保持lat和lng坐标的概览路径的kb和lb属性并不总是相同.上次我发的代码,它是kb和lb为几天,后来改成了mb,nb今天jb和kb.
我没有看到对象中的任何其他属性可以为我提供除上述之外的其他属性.其他类似问题的答案提到了这个问题.我在这里错过了什么吗?请任何可靠的解决方案
| 归档时间: |
|
| 查看次数: |
6457 次 |
| 最近记录: |