谷歌地图网页后返回不同的VS API

问题描述:

所以我通过谷歌地图API发送到指定地址:谷歌地图网页后返回不同的VS API

蒂尔登村,02052

我可以在上面打字找到它在地图上。当我使用下面的呼叫时,它会返回不准确的地图位置。我错过了什么吗?

function showAddress(address) { 
     if (geocoder) { 
     $('#mapblock').css('border','2px #CCC solid'); 
     geocoder.getLatLng(
      address, 
      function(point) { 
      if (!point) { 
          map.addControl(new GSmallZoomControl3D()); 

       alert(address + " not found"); 
      } else { 
       map.addControl(new GSmallZoomControl3D()); 
       map.setCenter(point, 13); 
       var marker = new GMarker(point); 
       map.addOverlay(marker); 
       //marker.openInfoWindow("test",{maxWidth:249}); 
      } 
      } 
     ); 
     } 
    } 

这是通过谷歌地图的结果: Google Maps REsult.

API response/Geocode and Map result

下面是从API /地理编码结果:

+0

您确定您从Google地图中获得了正确的位置吗?你期待什么结果?请提供一个演示问题(和您的预期结果)的[mcve]。你可能想看看:https://developers.google.com/maps/documentation/geocoding/best-practices – geocodezip

+0

好的,我会添加一些上面的帖子。 – BostonMacOSX

有两件事情要突出关于地址解析API请求在你的例子中。

  • '蒂尔登村02052'是不完整和模糊的。地理编码服务在模糊查询中效果不佳。我可以看到“蒂尔登村,02052”多个结果如图我的截图

enter image description here

你应该提供一个更精确的搜索字符串作为本文件中提到:

https://developers.google.com/maps/faq#geocoder_queryformat

也看看最佳实践,您可以找到解决模糊查询的方法

https://developers.google.com/maps/documentation/geocoding/best-practices

  • 的Medfield的房委会,你是指作为正确的结果有一个地址'30庞德街的Medfield,MA 02052,USA”,所以我希望'30庞德街,02052' 更准确地说:

https://google-developers.appspot.com/maps/documentation/utils/geocoder/#q%3D30%2520Pound%2520St%252C%2520%252002052