Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google maps 谷歌地图返回不同的web和API_Google Maps - Fatal编程技术网

Google maps 谷歌地图返回不同的web和API

Google maps 谷歌地图返回不同的web和API,google-maps,Google Maps,因此,我通过谷歌地图API发送当前地址: 蒂尔登村,02052 我可以在地图上找到它,只要在上面键入。当我使用下面的调用时,它返回一个不准确的地图位置。我错过什么了吗 function showAddress(address) { if (geocoder) { $('#mapblock').css('border','2px #CCC solid'); geocoder.getLatLng( address,

因此,我通过谷歌地图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});
            }
          }
        );
      }
    }
以下是谷歌地图的结果:


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

在您的示例中,关于地理编码API请求,有两件事需要强调

  • “Tilden村,02052”不完整且不明确。地理编码服务不能很好地处理不明确的查询。我可以看到“Tilden Village,02052”的多个结果,如我的屏幕截图所示

您应该提供本文档中提到的更精确的搜索字符串:

还可以看看最佳实践,从中可以找到解决不明确查询的方法

  • 您称之为正确结果的Medfield住房管理局的地址为“美国马萨诸塞州Medfield 30 Pound St 02052”,因此我认为“30 Pound St 02052”更准确:

你确定你从谷歌地图上找到了正确的位置吗?你期待什么结果?请提供一份说明问题(以及您的预期结果)的报告。你可能想看看:好的,我会在上面的帖子中添加一些东西。