Google Map地理编码在Forward API和Reverse API中获得不同的结果-在某些地址中

德鲁米尔·沙阿

转发API:https : //maps.googleapis.com/maps/api/geocode/json?address= 1045%20E%2024th% 20St,%20Minneapolis,% 20MN%2055404 &key=YOUR_API_KEY

结果

{
   "results":[
      {
         "address_components":[
            {
               "long_name":"1045",
               "short_name":"1045",
               "types":[
                  "street_number"
               ]
            },
            {
               "long_name":"East 24th Street",
               "short_name":"E 24th St",
               "types":[
                  "route"
               ]
            },
            {
               "long_name":"Phillips",
               "short_name":"Phillips",
               "types":[
                  "neighborhood",
                  "political"
               ]
            },
            {
               "long_name":"Minneapolis",
               "short_name":"Minneapolis",
               "types":[
                  "locality",
                  "political"
               ]
            },
            {
               "long_name":"Hennepin County",
               "short_name":"Hennepin County",
               "types":[
                  "administrative_area_level_2",
                  "political"
               ]
            },
            {
               "long_name":"Minnesota",
               "short_name":"MN",
               "types":[
                  "administrative_area_level_1",
                  "political"
               ]
            },
            {
               "long_name":"United States",
               "short_name":"US",
               "types":[
                  "country",
                  "political"
               ]
            },
            {
               "long_name":"55404",
               "short_name":"55404",
               "types":[
                  "postal_code"
               ]
            },
            {
               "long_name":"3833",
               "short_name":"3833",
               "types":[
                  "postal_code_suffix"
               ]
            }
         ],
         "formatted_address":"1045 E 24th St, Minneapolis, MN 55404, USA",
         "geometry":{
            "location":{
               "lat":44.9589308,
               "lng":-93.2592956
            },
            "location_type":"RANGE_INTERPOLATED",
            "viewport":{
               "northeast":{
                  "lat":44.96027978029149,
                  "lng":-93.25794661970849
               },
               "southwest":{
                  "lat":44.9575818197085,
                  "lng":-93.2606445802915
               }
            }
         },
         "place_id":"EioxMDQ1IEUgMjR0aCBTdCwgTWlubmVhcG9saXMsIE1OIDU1NDA0LCBVU0EiGxIZChQKEgmhxzziqTKzUhEX8ec1BmZglBCVCA",
         "types":[
            "street_address"
         ]
      }
   ],
   "status":"OK"
}

在反向API中,我使用了相同的几何位置Lat和Long

反向API:https//maps.googleapis.com/maps/api/geocode/json?latlng = 44.9589308,-93.2592956 &key = YOUR_API_KEY

结果

{
   "plus_code":{
      "compound_code":"XP5R+H7 Minneapolis, MN, USA",
      "global_code":"86P8XP5R+H7"
   },
   "results":[
      {
         "address_components":[
            {
               "long_name":"2400",
               "short_name":"2400",
               "types":[
                  "street_number"
               ]
            },
            {
               "long_name":"11th Avenue South",
               "short_name":"11th Ave S",
               "types":[
                  "route"
               ]
            },
            {
               "long_name":"Midtown Phillips",
               "short_name":"Midtown Phillips",
               "types":[
                  "neighborhood",
                  "political"
               ]
            },
            {
               "long_name":"Minneapolis",
               "short_name":"Minneapolis",
               "types":[
                  "locality",
                  "political"
               ]
            },
            {
               "long_name":"Hennepin County",
               "short_name":"Hennepin County",
               "types":[
                  "administrative_area_level_2",
                  "political"
               ]
            },
            {
               "long_name":"Minnesota",
               "short_name":"MN",
               "types":[
                  "administrative_area_level_1",
                  "political"
               ]
            },
            {
               "long_name":"United States",
               "short_name":"US",
               "types":[
                  "country",
                  "political"
               ]
            },
            {
               "long_name":"55404",
               "short_name":"55404",
               "types":[
                  "postal_code"
               ]
            },
            {
               "long_name":"3806",
               "short_name":"3806",
               "types":[
                  "postal_code_suffix"
               ]
            }
         ],
         "formatted_address":"2400 11th Ave S, Minneapolis, MN 55404, USA",
         "geometry":{
            "bounds":{
               "northeast":{
                  "lat":44.9589961,
                  "lng":-93.2589414
               },
               "southwest":{
                  "lat":44.958912,
                  "lng":-93.25912079999999
               }
            },
            "location":{
               "lat":44.958968,
               "lng":-93.2590273
            },
            "location_type":"ROOFTOP",
            "viewport":{
               "northeast":{
                  "lat":44.9603030302915,
                  "lng":-93.25768211970849
               },
               "southwest":{
                  "lat":44.9576050697085,
                  "lng":-93.2603800802915
               }
            }
         },
         "place_id":"ChIJTb-V4qkys1IRukelu4LNRgI",
         "types":[
            "premise"
         ]
      },

在这里我在反向Google API中获得了另一个地址,如果我需要在链接中添加任何内容或其他内容,请帮帮我

Xomena

关于您的问题,您应该注意,并非所有地址都显示在Google数据库中。有时,地址只是根据其他数据(例如街道名称和街道编号范围)进行插值,因此Google甚至可以针对其数据库中缺少的地址来预测其位置。

对某个地址进行地址解析时,应检查结果的location_type是什么。在您的示例中,location_type为RANGE_INTERPOLATED这意味着Google在其数据库中没有地址“ MN 45404,Minneapolis,Minneapolis,1045 E 24th St,明尼苏达州55404”的确切ROOFTOP地址,并且位置已插值。插值位置的另一个明显标志是位置ID值很长。在您的示例中是EioxMDQ1IEUgMjR0aCBTdCwgTWlubmVhcG9saXMsIE1OIDU1NDA0LCBVU0EiGxIZChQKEgmhxzziqTKzUhEX8ec1BmZglBCVCA

在此处输入图片说明

那么,如果您现在对这个插值地址的坐标进行反向地理编码(44.9589308,-93.2592956),会发生什么?反向地理编码服务将优先使用现有的ROOFTOP地址,并将首先返回具有location_type的最接近的结果,ROOFTOP然后返回其他内插的结果。

在您的示例中,有几个返回反向地理编码的结果。您可以在我的屏幕截图中看到它们:

在此处输入图片说明

第一个结果(标记1)是位置类型为ROOFTOP的“ 2400 11th Ave S,明尼阿波利斯,美国MN 55404”,第二个结果(标记2)是位置类型为ROOFTOP的“ 2408 11th Ave S,Minneapolis,MN 55404,美国” ROOFTOP,第三个(标记3)是'1005 E 24th St,Minneapolis,MN 55404,USA'再次ROOFTOP,唯一的结果是RANGE_INTERPOLATED地址'1045 E 24th St,Minneapolis,MN 55404,USA'

请注意,您可以要求反向地理编码服务仅提供某些位置类型的结果。例如,您可以说您只对RANGE_INTERPOLATED结果感兴趣:

https://maps.googleapis.com/maps/api/geocode/json?latlng=44.9589308%2C-93.2592956&location_type=RANGE_INTERPOLATED&key=YOUR_API_KEY

在这种情况下,反向地理编码的第一个结果将是您的范围插值地址,如我的屏幕截图所示

在此处输入图片说明

希望我的回答能澄清您的疑问。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Google Map API:如何管理地理编码结果中的不同“ address_components”?

地理编码API和Google Map之间的返回数据不同

从地理编码结果中获取城市Google Maps Api

Google地理编码API在某些位置未返回结果

地址数组中的多个标记Google Map API v3,并在pageLoad上进行地理编码时避免OVER_QUERY_LIMIT

回调函数中的Google Map地理编码TypeError

Google地理编码API找不到地点API返回的地址

如果我的某些地址沒有緯度/經度,如何在 Google Maps API 中對地址進行地理編碼?

Google Maps API错误地对地址进行地理编码

使用Google Maps API对地址进行地理编码

Google Maps API:反向地理编码和地址打印

asp.net中Google Map API v3中的反向地理编码本地化

针对IN(印度)和CA(加拿大)的国家/地区alpha2代码的Google Map API地理编码错误

本机浏览器和Node.js中的JavaScript函数声明获得不同的结果

使用mongo和mongoClient从同一查询中获得不同的投影结果

Google Maps API-地理编码和附近搜索

JAVA Google地理编码API获取城市

带有Google地理编码API的Alamofire

从Google地理编码API返回邻居?

Python Google Maps地理编码API

Google Javascript API地理编码限制

使用Google的地理编码API从JSON数组中获取正确的值

受限Google API密钥在反向地理编码中不起作用

Google Map Places API getPlace()仅返回某些地址的名称属性

NodeJs Buffer.toString()在7.x和8.x版本中获得不同的结果(模块加密)

如何从Google Map中的经度和纬度获取地址位置?

python-API Key中的地理编码

使用多线程在不同的运行中获得不同的结果

实时地理编码应使用什么:Google API或Android API?