2016-01-17 236 views
-2

我使用谷歌地圖API在本地主機地址自動完成。地址抓取正常,但是,我想獲取緯度/經度,但我的代碼不再工作,該怎麼辦?獲取谷歌地圖getplace經緯度和長

<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=true"></script> 
place = places.getPlace(); 
address = place.formatted_address; 
latitude = place.geometry.location.H; 
longitude = place.geometry.location.L; 

乾杯所有

+1

加載Maps JS文件時,不再需要在URL中傳遞'sensor'屬性。 – duncan

回答

0

你總是可以參考place.geometry.location對象的緯度和經度性質是這樣的:

var lat = place.geometry.location.lat(); 
var lng = place.geometry.location.lng(); 

的PlaceGeometry類的location屬性是一個經緯度對象:

HL屬性是無證,且易於與地圖API的每個新版本改變,而不應使用。

相關問題