Google Directions Service API 3将错误的结果返回到地图

时间:2016-01-27 07:08:52

标签: google-maps google-maps-api-3 map-directions

使用Google方向服务查找地图下面列出的两个地址

<access token>

选择它通过谷歌地图方向直接它工作正常

链接:https://www.google.co.in/maps/dir/Keystone+Place-Blair's+Ferry,+6126+Rockwell+Drive+Northeast,+Cedar+Rapids,+IA+52402,+United+States/Cottage+Grove+Place,+2115+1st+Avenue+Southeast,+Cedar+Rapids,+IA+52402,+United+States/@42.0179234,-91.6739759,13z/data=!3m1!4b1!4m13!4m12!1m5!1m1!1s0x87e4f0459aacb105:0x63c416fc0edc61d6!2m2!1d-91.6475339!2d42.039779!1m5!1m1!1s0x87e4f0d795c1b96b:0xa1ccbbf6400b01aa!2m2!1d-91.6362972!2d41.9959428?hl=en

使用Direction Service时,它的工作方式不同。 查找以下示例

http://jsfiddle.net/MRHQ4/291/(致作者:Shreerang Patwardhan)

当我从源和目标

中删除Address2时,它工作正常

2 个答案:

答案 0 :(得分:1)

单位和公寓信息可能会导致地理编码器中的解析问题。如果可以,请尝试尽可能地删除它们。将地址更改为

var start = "2115 First Avenue SE, Cedar Rapids, IA, 52402";     //Set the source/ origin
var end = "6126 Rockwell Dr, Cedar Rapids, IA, 52402";

你会发现它运作得更好。

Reduced Address Information

With Neighborhood Information

With Apt/Unit Information

答案 1 :(得分:0)

&#39; Cottage Grove Place&#39;和Keystone Place&#39;不是地址2,这些是地名(或者你可以说地方标题),只需将它们移动到地址的开头(没有其他变化),如下所示,它工作正常:

var start = "Cottage Grove Place, 2115 First Avenue SE Unit 1306, Cedar Rapids, IA, 52402";     //Set the source/ origin

var end = "Keystone Place, 6126 Rockwell Dr. Apt 128, Cedar Rapids, IA, 52402";  //Set the destination

我测试过它工作正常,请复习,谢谢。