2017-08-10 16 views
0

我想在javascript中獲取地址的座標。而assingning地址解析器給一個變量爲:如何使用webpack在JavaScript中獲取地址的地理編碼?

var geocode = new google.maps.Geocoder();

它投擲:google is not defined

+0

檢查[this](https://developers.google.com/maps/documentation/javascript/geocoding)和[this](https://developers.google.com/maps/documentation/geocoding/intro),然後在你的HTML鏈接你的地理編碼api,它不會拋出任何錯誤。 – Durga

回答

0

您可以嘗試使用geocoding web Api。而讓舒爾你加入這個腳本

<script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap"> </script>

這裏initmap'是功能,在其中創建地理編碼對象。

+0

謝謝,但我不應該在我的應用程序中使用腳本標記。 –

+0

谷歌對象在該腳本中定義。如果你不能添加它,你會發送web請求,如鏈接所示 – AlexK

相關問題