place_administrative_area_level_1返回相同区域的不同值 [英] place_administrative_area_level_1 return different values for same area

查看:113
本文介绍了place_administrative_area_level_1返回相同区域的不同值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Google Map API获取西班牙马德里一所房屋的街道地址.然后我获得了place_administrative_area_level_1的以下信息.

I used google map api to get a street address of a house in Madrid, Spain. Then I got the following for place_administrative_area_level_1.

place_administrative_area_level_1_short:马德里自治大学 place_administrative_area_level_1_long:马德里自治大学

place_administrative_area_level_1_short: Comunidad de Madrid place_administrative_area_level_1_long: Comunidad de Madrid

然后,我将这些详细信息保存到数据库中.现在,我要搜索我从马德里保存的地址.因此,从前端开始,我再次搜索西班牙马德里的Google Place API.然后,谷歌向我返回了place_administrative_area_level_1的以下内容.

Then I saved those details to database. Now I want to search the addresses I saved from Madrid. So from front end, again I search google place api by Madrid, Spain. Then google returns me the following for place_administrative_area_level_1.

place_administrative_area_level_1_short:马德里自治区 place_administrative_area_level_1_long:马德里自治区

place_administrative_area_level_1_short: Community of Madrid place_administrative_area_level_1_long: Community of Madrid

看到区别了吗?现在,我无法使用该字符串搜索数据库,因为它具有不同的值.在两种情况下,我都发送language = en.那么,为什么要为此地址字段返回不同的值呢? 唯一的区别是,对于第一个来说,我就像马德里一所房屋的街道地址一样使用.第二,我只使用了西班牙马德里.但是在两种情况下,它都应该为place_administrative_area_level_1返回相同的值.因此,我无法按单个值搜索数据库.

See the difference? Now I can't use this string to search my database as it has different value. In both cases, I am sending language=en. So why it is returning different values for this address field? The only difference is that, for the 1st one, I used like a street address of a house in Madrid. In second instance, I used like Madrid, Spain only. But in both cases, it should return the same value for place_administrative_area_level_1. Because of this, I can't search my database by a single value.

推荐答案

这是因为Geocoding API Web服务应用了本地化策略.您可以在以下文章中了解它:

This is because of localization policy applied by Geocoding API web service. You can read about it in the following post:

https://mapsplatform.googleblog.com /2014/11/localization-of-street-addresses-in.html

现在,由Google Maps Geocoding API返回的

街道级地址偏爱本地语言,同时使仅阅读所请求语言的用户和本地人都尽可能地理解该地址

Street-level addresses returned by the Google Maps Geocoding API now favor the local language, while keeping the address understandable as much as possible for both a user who only reads the requested language as well as locals.

如果本地语言和用户语言都使用相同的字母,则Geocoding API现在将返回街道和位置的本地名称.

If the local language and user language both use the same alphabet, the Geocoding API will now return the local names for the streets and localities.

在您的示例中,第一个请求搜索街道级别的地址,因此您获得了西班牙语的地址部分管理名称,如上所述.

In your examples the first request searches street level address, so you get a Spanish name for address component administrative_area_level_1 Comunidad de Madrid as mentioned above.

第二个请求不是街道级别的地址,因此未应用上述策略,并且您根据语言参数(英语为Community of Madrid)获得了一个名称.

The second request is not a street level address, so the aforementioned policy is not applied and you get a name according to the language parameter which is English Community of Madrid.

我相信您可能对以下功能请求非常感兴趣:

I believe you might be strongly interested in the following feature request:

在每个address_components中添加place_id

实施此功能请求后,您将能够比较地点ID而不是地址组件中的名称.

Once this feature request is implemented you will be able to compare place ids instead of the names in address components.

我希望这能解决您的疑问.

I hope this addresses your doubt.

这篇关于place_administrative_area_level_1返回相同区域的不同值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆