转发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中获得了另一个地址,如果我需要在链接中添加任何内容或其他内容,请帮帮我
关于您的问题,您应该注意,并非所有地址都显示在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] 删除。
我来说两句