-3
我已经在很多网站上搜索了一个解决方案,但没有一个人工作。如何在JavaScript中找到经纬度的城市名称?
由于时间我试图通过使用纬度和经度值,我将从一个输入框让我x
,y
变量来获得城市的名称,但没有例子的工作。
我也读过谷歌地图API,但没有用。
我已经有一个API密钥。
你也许有任何解决方案?
这个例子,我从网站上得到了和尝试,但没有成功:
function myFunction() { var x='xxxxx'; var y='xxxxx'; //my coordinates
var geocoder = new google.maps.Geocoder;
var latlng = {lat: parseFloat(x), lng: parseFloat(y)};
geocoder.geocode({'location': latlng}, function(results, status) {
if (status === google.maps.GeocoderStatus.OK) {
// ...
} else {
window.alert('No results found');
}
} else {
window.alert('Geocoder failed due to: ' + status);
}
});
}
试试这个:http://stackoverflow.com/questions/67975 69/get-city-name-using-geolocation – Bassie
http://www.geocodezip.com/v3_GoogleEx_geocoding-reverse2postcodeD.html – geocodezip
哇这就是谢谢:)喜欢这个网站! – sinanto