2016-10-04 79 views
-2

我們使用Google API從自動填充輸入中獲取地址。帶有自動完成功能的Google Maps JavaScript API

<script src="https://maps.googleapis.com/maps/api/js?key=XXXXX&signed_in=true&libraries=places&callback=initAutocomplete" async defer></script> 

的源代碼可以在這裏找到: https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform?hl=de

現在我在想,如果我能得到來自該請求的經度緯度。因此,我們可以訪問Google地圖並計算距離我們的起點的距離。

+1

是的,這是在響應 - 這將會是'position.geometry.location'的例子 - 同樣,地址的經緯度,並假設你有同樣的「開始點」 - 你不需要谷歌地圖來計算直線距離 - 這只是一些數學 –

+0

@Jaromanda X謝謝,alert(position.geometry.location);雖然沒有價值。我必須使用其他功能嗎? – Isengo

+1

看到了,你已經發布了ZERO代碼,所以我不知道你在哪裏發佈了* alert *電話以知道你是否做得對 –

回答

0

所以將溶液在fillInAddress使用

place.geometry.location.lat()緯度

place.geometry.location.lng()用於longtidue

()函數聲明var地點後。

感謝@JaromandaX

相關問題