首页 文章

Google Places API Web服务与Geocode API的结果不同

提问于
浏览
-1

使用以下地址时:

“107-25 CONTINENTAL AVE Forest Hills NY 11375”

我得到两个不同的街道号码 .

为什么是这样?

Google Maps Geocoding API

GET https://maps.googleapis.com/maps/api/geocode/json?address=

回报

"address_components" : [
            {
               "long_name" : "107-12",
               "short_name" : "107-12",
               "types" : [ "street_number" ]
            },
            {
               "long_name" : "Continental Avenue",
               "short_name" : "Continental Ave",
               "types" : [ "route" ]
            },
            {
               "long_name" : "Forest Hills",
               "short_name" : "Forest Hills",
               "types" : [ "neighborhood", "political" ]
            },
            {
               "long_name" : "Queens",
               "short_name" : "Queens",
               "types" : [ "political", "sublocality", "sublocality_level_1" ]
            },
            {
               "long_name" : "Queens County",
               "short_name" : "Queens County",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "New York",
               "short_name" : "NY",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "United States",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            },
            {
               "long_name" : "11375",
               "short_name" : "11375",
               "types" : [ "postal_code" ]
            }
         ],
         "formatted_address" : "107-12 Continental Ave, Forest Hills, NY 11375, USA",

当使用相同的地址时

Google Places API Web Service

GET https://maps.googleapis.com/maps/api/place/js/PlaceService.GetPlaceDetails

返回:

"address_components" : [
     {
        "long_name" : "107",
        "short_name" : "107",
        "types" : [ "street_number" ]
     },
     {
        "long_name" : "Continental Avenue",
        "short_name" : "Continental Ave",
        "types" : [ "route" ]
     },
     {
        "long_name" : "Forest Hills",
        "short_name" : "Forest Hills",
        "types" : [ "neighborhood", "political" ]
     },
     {
        "long_name" : "Queens",
        "short_name" : "Queens",
        "types" : [ "sublocality_level_1", "sublocality", "political" ]
     },
     {
        "long_name" : "Queens County",
        "short_name" : "Queens County",
        "types" : [ "administrative_area_level_2", "political" ]
     },
     {
        "long_name" : "New York",
        "short_name" : "NY",
        "types" : [ "administrative_area_level_1", "political" ]
     },
     {
        "long_name" : "United States",
        "short_name" : "US",
        "types" : [ "country", "political" ]
     },
     {
        "long_name" : "11375",
        "short_name" : "11375",
        "types" : [ "postal_code" ]
     }
  ]

1 回答

  • 0

    除了已经简要提到的内容之外,两个不同的输出 - 我们真的在讨论一个不会影响结果的可忽略的数值 - 表明这两个API旨在解决不同的目的 .

    Geocoding 是关于将人类可读地址转换为数字坐标,它应该用于complete / unambiguous addresses.注意ROOFTOPS返回结果的精度 . 我们在这里看到的误差约为0.11米 .

    这就像问谷歌:“嘿谷歌,给我这个字符串最相关的地址”

    Places API相反......(对很多人来说,这可能不是那么明显)

    允许您查询各种类别的地点信息,例如:机构,重要的兴趣点,地理位置等 .

    这就像问:“嘿谷歌,这里你有一个字符串,返回这些类别中的所有内容” . 换句话说,它就像收到一些混合锅一样......

    反直觉地,我们可以推断出传递给Places API的字符串中必定存在某些内容,使服务器将连字符后的第二个数字转换为“略微”不同的数字然后返回它 .

相关问题