2016-09-15 116 views
2

我們有一個應用程序,用戶可以報告事件並希望允許按關鍵字搜索。 Google Places API(我試過附近的搜索,文本搜索和自動完成功能)僅返回商家信息,但有時用戶可能在住宅街道上。我如何讓地點返回住址?我可以使用Google Places API返回住宅地址嗎?

我知道數據在那裏,因爲如果您在Google地圖上進行搜索或使用地理編碼API,則可以獲得確切的地址。

實施例(採摘在倫敦的隨機點): https://maps.googleapis.com/maps/api/place/nearbysearch/json?&key=[YOUR_KEY]&radius=50000&location=51.611499,-0.026750&keyword=sinclair

返回

Sinclair Pharma, 1st Floor Whitfield Court, 30-32 Whitfield Street, London 
Sinclair Pharmaceuticals Ltd, Godalming Business Centre, Woolsack Way, Godalming 
Sinclair Hammelton Bromley, 23 High Street, Bromley 
Sinclair & Rush Ltd, 20/20 Business Estate, Spectrum West, Saint Laurence Avenue, Maidstone 
Sinclair Hammelton Petts Wood, 9 Fairway, Orpington 
Sinclair Till Flooring Co Ltd, 793 Wandsworth Road, London 
etc 

https://maps.googleapis.com/maps/api/geocode/json?&key=[YOUR_KEY]&latlng=51.611499,-0.026750

返回

148 Sinclair Rd, London E4 8PR, UK 

回答

1

是否使用自動完成與type=geocodetype=address做你想做的事(link to docs)?

https://maps.googleapis.com/maps/api/place/autocomplete/json?&key=[YOUR=KEY]&type=geocode&radius=50000&location=51.611499,-0.026750&input=5%20sinclair 
+0

不,我試過自動完成。添加types = address不會給我任何不同的結果 - 它只返回道路,例如「英國倫敦辛克萊路」。 –

+0

請嘗試檢查此演示中的「地址」:https://google-developers.appspot.com/maps/documentation/javascript/examples/full/places-autocomplete─您應該看到僅建議了地址,並且沒有任何商家。 – miguev

+0

它仍然沒有門牌號返回道路。與OS Places Find API比較,該API返回街道上各個房屋號碼的結果。 –

相關問題