如何根據給定距離(以公里爲單位)從經度和緯度的另一個城市過濾給定的經度和緯度城市列表。過濾城市的經緯度與其他城市的距離(經緯度)?
我想使用Google Maps API(javascript)或其他適合的解決方案。
cities = {
['zürich','47.368650', '8.539183'],
['City2','21.568650', '2.439183'],
['City3','41.568650', '4.439183']
}
distance = 2; //2 km
targetCity = ['zürich','47.368650', '8.539183'];
需要:getNearCities(targetCity,distance,cities);
謝謝
你可以看到這個頁面http://www.movable-type.co.uk/scripts/latlong上haversine公式。 html –
查看google距離矩陣api https://developers.google.com/maps/documentation/distancematrix/ – Ronin