例如,当我在http://www.infoghidromania.com/harta_romania.html上输入地址时网站,然后按提交,它应该提取 GPS 坐标。
最佳答案
该网站使用谷歌地图 API。您可以使用相同的 API 来获取您可以在 Google map 上找到的任何位置的经度/纬度。
Javascript 代码示例:
var geocoder = new google.maps.Geocoder();
geocoder.geocode( { 'address': '<YOUR_SEARCH_STRING_HERE>' }, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
alert("Lang/Lat : " + results[0].geometry.location.lat() + " " +results[0].geometry.location.lng());
} else {
alert('Error: ' + status);
}
});
工作示例:
关于php - 如何获取给定城市/国家的经度/纬度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16984688/