Android:地址(来自地理编码)有固定格式吗?
我需要确定地理位置的地址,所以我使用了 GeoCoder 和 Address,我尝试打印一个 Address 对象并得到以下结果:(
出于隐私原因,我使用了一些虚假数据,但我在设备上收到的数据是real)
Address[addressLines=[0:"123 ABC St",1:"墨尔本 VIC 1234",2:"澳大利亚"],feature=123,admin=维多利亚,sub-admin=null,locality=墨尔本,thoroughfare=ABC St,postalCode=1234,countryCode=AU,countryName=Australia,hasLatitude=true,latitude=-123.321,hasLongitude=true,longitude=123.321,phone=null,url=null,extras=null]
现在我想知道,可以吗我假设:
- 地址行索引 0 始终是街道地址?
- 索引 1 和 to 是郊区、州、邮政编码对,索引 2 是国家/地区?
- “特征”实际上是街道号码(即123)?
- “admin”是状态吗?
如果格式不固定,如何获取地址信息? 谢谢!
I need to determine the address for a geo location, so I used GeoCoder and Address, I tried to print an Address object and got the following:
(for privacy reason, I used some fake data, but the data I received on my device is real)
Address[addressLines=[0:"123 ABC St",1:"Melbourne VIC 1234",2:"Australia"],feature=123,admin=Victoria,sub-admin=null,locality=Melbourne,thoroughfare=ABC St,postalCode=1234,countryCode=AU,countryName=Australia,hasLatitude=true,latitude=-123.321,hasLongitude=true,longitude=123.321,phone=null,url=null,extras=null]
Now I'm wondering, can I assume that:
- address line index 0 is always the street address?
- and index 1 and to is the suburb, state, postcode pair, and index 2 is the country?
- "feature" is actually the street number(ie 123)?
- "admin" is state?
If the format is NOT fixed, how do I get address information?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为格式不是固定的,您不应该依赖数组索引。来自文档:
我相信地理编码服务是由在后台运行的谷歌地图服务实现的。您应该使用 Address 类来获取您需要的地址的元素。
I don't think that the format is fixed and you should not rely on the array indexes. From the docs:
The geocoding service is implemented by the Google Maps service which runs in the backgroind I believe. You should use Address class to fetch the elements of the address that you require.
这是一个可能有帮助的片段。
->使用 GeoCoder
请记住,GeoCoder 并未在所有 Android 设备中实现:|在这种情况下,您可以直接使用 Google API
-> http://code.google.com/apis/maps/documentation/geocoding/
Here is a snippet that may help.
-> using GeoCoder
Please keep in mind, GeoCoder is NOT implemented in all Android devices :| in this case, you can use Google API directly
-> http://code.google.com/apis/maps/documentation/geocoding/