2012-12-09 74 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/)。

如果你需要比這更準確,那麼你正在製作一個相當大的參考數據庫。

相關問題