谷歌地图 - 错误的(不同的)路线方向

时间:2013-06-14 12:00:43

标签: google-maps-api-3

我尝试从两个点获取路线方向的指示,但是当我通过源代码(coorect路径)给出坐标时,路线看起来不同,而不是函数从文本框中获取它们。我想让你知道我有兴趣只通过坐标而不是通过地址找到路线

提前谢谢

表单源代码(正确的路由) - http://www.touchsmart.gr/stackoverflow_map/route_from_variable.html

来自文本框(错误的路线) - http://www.touchsmart.gr/stackoverflow_map/route_from_text.html

1 个答案:

答案 0 :(得分:1)

这是两件不同的事情。正确的路由是传递google.map.LatLng对象,不正确的路由不是。要使用地理坐标,您需要传入google.map.LatLng对象,否则坐标会被地理编码。

destination LatLng|string   Location of destination. This can be specified as either a string to be geocoded or a LatLng. Required.
origin  LatLng|string   Location of origin. This can be specified as either a string to be geocoded or a LatLng. Required.

有关如何将逗号分隔的字符串转换为google.maps.LatLng对象,请参阅this question

相关问题