0
我想查找澳大利亚哪个城市的最近城市example在此查看示例。我尝试过使用Google API,但没有用。我该如何实现这一目标。你可以帮帮我吗?如何在Google地图API中找到距离最近的城市
代码
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var request = {
location: fenway,
radius: 500,
types: ['store']
};
var service = new google.maps.places.PlacesService(map);
service.search(request, callback);
function callback(results, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {
var lat = results[i].geometry.location.lat();
var geocoder = new google.maps.Geocoder();
var lng = results[i].geometry.location.lng();
var latlng = new google.maps.LatLng(lat, lng);
geocoder.geocode({
'latLng': latlng
}, function (result, status1) {
if (status == google.maps.GeocoderStatus.OK) {
if (result[1]) {
console.log(result[1]);
}
} else {
alert("Geocoder failed due to: " + status1);
}
});
}
}
}
我想在城市附近不喜欢商店等。我必须找到在澳大利亚郊区有哪些近,而我给
我添加了我的代码,我试过了。你有什么建议吗? – muthu 2012-07-25 12:27:10
以前也曾经有过相同的问题:http://stackoverflow.com/search?q=nearest+towns+cities&submit=search – Marcelo 2012-07-25 12:56:50