2012-12-09 73 views
3

我正在使用Google Places Auto自动完成API。如果我搜索一个特定的郊区,让我们说里士满澳大利亚维多利亚州我得到以下地址组件返回:如何使用Google地图API获取郊区的父城市?

0:Object 
    long_name: "Richmond" 
    short_name: "Richmond" 
    types: Array[2] 
     0: "locality" 
     1: "political" 

1: Object 
    long_name: "Victoria" 
    short_name: "VIC" 
    types: Array[2] 
     0: "administrative_area_level_1" 
     1: "political" 

2: Object 
    long_name: "Australia" 
    short_name: "AU" 
    types: Array[2] 
     0: "country" 
     1: "political" 

这是伟大的,但里士满是墨尔本的一个郊区,我的应用程序的目的,我需要知道这一点。如果地区在一个地方,我怎样才能让API返回父城市?如果你看看下面的URL,你可以看到里士满在澳大利亚维多利亚州的墨尔本,所以我假设它有可能以某种方式通过API获取这些信息?

https://maps.google.com/maps/place?q=Richmond&ftid=0x6ad64259018db945:0x5045675218ce810

回答

1

唉城市和/或地区的信息是不包括在地理编码API返回。

对于基于位置的搜索粗略的解决方案,我做公里半径城市和地区:

Worldwide No filter 
Country  Available from geocode 
State  Available from geocode 
Region  50 KM Radius from latlong 
City  20 KM Radius from latlong 
Postcode Available from geocode 
Suburb  Available from geocode (Locality) 
Radius  User defined radius from latlong 

我也尝试使用“边界”值,但没有真正的成功(https://developers.google.com/maps/documentation/geocoding/)。

如果你需要比这更准确,那么你正在制作一个相当大的参考数据库。

相关问题