【问题标题】:Does Google Maps website return the equivalent of the first result returned by Google Maps Geocoding API?Google Maps 网站是否返回与 Google Maps Geocoding API 返回的第一个结果等效的结果?
【发布时间】:2016-06-12 09:36:48
【问题描述】:

有人知道谷歌地图在显示搜索位置的纬度/经度方面是否有任何默认设置?

我正在使用 Google Maps Geocoding API 来查找用户输入的搜索地址的地理位置 lat/lng 值。我想尽可能地将结果与 Google 地图匹配 - 是否可以像始终获取 API 返回的第一个结果一样简单?

示例:如果我在 Google 地图中搜索“卡塞尔”,则 lat/lng 结果为 51.3149724,9.3904035。

Google Maps result for searching "Kassel"

使用 Google API 搜索会产生两个结果,其中第一个结果的位置值比第二个更接近 Google 地图:

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "Kassel",
               "short_name" : "Kassel",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Kassel",
               "short_name" : "KS",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Hesse",
               "short_name" : "HE",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Germany",
               "short_name" : "DE",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Kassel, Germany",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 51.36940509999999,
                  "lng" : 9.570128199999999
               },
               "southwest" : {
                  "lat" : 51.2603671,
                  "lng" : 9.3511015
               }
            },
            "location" : {
               "lat" : 51.3127114,
               "lng" : 9.4797461
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 51.36940509999999,
                  "lng" : 9.570128199999999
               },
               "southwest" : {
                  "lat" : 51.2603671,
                  "lng" : 9.3511015
               }
            }
         },
         "place_id" : "ChIJHWx6n04_u0cRRxciWD1jhC8",
         "types" : [ "locality", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Kassel",
               "short_name" : "Kassel",
               "types" : [ "sublocality_level_1", "sublocality", "political" ]
            },
            {
               "long_name" : "Biebergemünd",
               "short_name" : "Biebergemünd",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Darmstadt",
               "short_name" : "DA",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Hessen",
               "short_name" : "HE",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Germany",
               "short_name" : "DE",
               "types" : [ "country", "political" ]
            },
            {
               "long_name" : "63599",
               "short_name" : "63599",
               "types" : [ "postal_code" ]
            }
         ],
         "formatted_address" : "Kassel, 63599 Biebergemünd, Germany",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 50.2173498,
                  "lng" : 9.3059744
               },
               "southwest" : {
                  "lat" : 50.18299649999999,
                  "lng" : 9.271353399999999
               }
            },
            "location" : {
               "lat" : 50.2066898,
               "lng" : 9.279060399999999
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 50.2173498,
                  "lng" : 9.286410699999999
               },
               "southwest" : {
                  "lat" : 50.2006739,
                  "lng" : 9.271353399999999
               }
            }
         },
         "place_id" : "ChIJG4zo1CMvvUcRQPWOqlJDIgo",
         "types" : [ "sublocality_level_1", "sublocality", "political" ]
      }
   ],
   "status" : "OK"
}

我能找到的唯一文档如下:

为什么 Google Maps API 地理编码器提供的位置与 Google Maps 不同? API 地理编码器和谷歌地图地理编码器有时使用不同的数据集(取决于国家)。 API 地理编码器偶尔会使用新数据进行更新,因此您可以预期结果会随着时间的推移而发生变化或改进。

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

【问题讨论】:

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


    【解决方案1】:

    (有根据的猜测)

    我相信 Google 地图也会根据您帐户中以前的地图和位置搜索为您提供结果。

    很难相信他们使用提供给开发人员的相同 API 却没有重大改进。

    结果可能还会考虑以前的网络搜索、您的位置等。

    开发者 API 只是他们使用的一小部分功能。

    希望这会有所帮助!

    【讨论】:

    • 是的,我想我同意你的观点——谷歌地图的功能比 API 更强大是有道理的。正如用户 KENdi 正确指出的那样,它还取决于您搜索的域。所以我猜没有简单的答案!还是谢谢!
    【解决方案2】:

    您的结果无法与 Google 地图完全匹配,因为 Google 地图地理编码 API 返回的地址结果受发送请求的地区(通常是国家/地区)影响。例如,如果从美国境内的域发送的搜索结果可能与从西班牙发送的搜索结果不同。

    对于正式启动主要 Google 地图应用程序的每个域,地理编码结果可能存在偏差。请注意,偏差只偏爱特定领域的结果;如果在此域之外存在更多相关结果,则可能包含它们。

    更多信息请点击link

    【讨论】:

    • 这对谷歌地图来说是有道理的,但我认为对于API,除非你在参数中指定区域,否则它将使用美国的默认值。在这种情况下,我从未设置会影响域的“区域”参数。确实,将 API 调用中的区域与在 Google 地图上搜索时使用的域相匹配(即,如果我在 Google 地图网站上从爱尔兰搜索,我应该在我的 Google API 调用中将区域更改为爱尔兰)会按结果顺序带来更好的匹配。我认为这不能保证完全匹配。还是谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-19
    • 1970-01-01
    • 1970-01-01
    • 2015-03-25
    • 2016-08-07
    • 1970-01-01
    相关资源
    最近更新 更多