如何验证2坐标之间的距离?

sha*_*ikh 1 google-maps geolocation google-maps-api-3 google-maps-markers

我正在使用这种方法来计算2个坐标之间的距离

http://code.google.com/apis/maps/articles/phpsqlsearch.html#findnearsql
Run Code Online (Sandbox Code Playgroud)

例如我有两个坐标(lat和lng)

first coordinate: 37, -122
second coordinate:37.386337, -122.085823
Run Code Online (Sandbox Code Playgroud)

我通过上面的方法得到这些坐标之间的距离27.1097282198804(英里).

请告诉我任何方法来验证这个距离?

Man*_*rks 6

您还可以使用Google Maps API 几何库.

firstLatLng = new google.maps.LatLng(37,-122);
secondLatLng = new google.maps.LatLng(37.386337, -122.085823);
distance = google.maps.geometry.spherical.computeDistanceBetween(firstLatLng,secondLatLng);
Run Code Online (Sandbox Code Playgroud)