請向我推薦我如何從地址獲取經度和緯度的不同方式,以便我可以將值傳遞給IONIC中的當前位置框架。如何使用離子地圖中的java腳本在谷歌地圖中獲取經度和緯度
到現在我能夠得到Lat Long網從地址:
address$scope.geocodeAddress = function() {
var address = document.getElementById('from').value;
geocoder.geocode({
'address': address
}, function(results, status) {
if (status === 'OK') {
map.setCenter(results[0].geometry.location);
console.log("latlng-->" + results[0].geometry.location);
var latitude = results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert('Geocode was not successful: ' + status);
}
});
你能告訴我們更多關於你正在嘗試做什麼,並告訴我們一些你已經嘗試過的代碼嗎? – Dexter
嗨德克斯特,我試圖從地址獲取經緯度,並將其傳遞到Google本地api中從我的離子應用程序啓動。直到現在,我已經成功地從地址 –