獲得經/緯度我有一個使用谷歌的地方API來自動提示的位置,像這樣一個搜索字段:如何從選擇的結果
<input type="text" id="addressInput" name="addressInput" class="span3 search-query" placeholder="Enter location..">
<script>
var autocomplete = new google.maps.places.Autocomplete($("#addressInput")[0], {});
google.maps.event.addListener(autocomplete, 'place_changed', function() {
var place = autocomplete.getPlace();
console.log(place.address_components);
});
</script>
當用戶鍵入一個addrress或城市,它表明就好了。但是一旦用戶點擊了結果,我如何從用戶中檢索該選定選項的緯度和經度?
谷歌示例似乎是基於放下標記找到它們。我沒有在地圖上顯示任何東西。
我已經看到了,我只是不知道你是怎麼得到它的地址解析什麼都解決了用戶最終從自動完成結果輸入或選擇 – thindery 2012-02-23 21:17:13
你看過「幾何」對象嗎?即console.log(place.geometry);根據文檔,它的位置部分包含Long和Lat。 – lkaradashkov 2012-02-23 21:33:04