Created
January 13, 2021 04:03
-
-
Save gee1k/41d3878f980816bb0ac0452319c1d39c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function distance(latlng1, latlng2) { | |
var rad = Math.PI / 180, | |
lat1 = latlng1.lat * rad, | |
lat2 = latlng2.lat * rad, | |
a = Math.sin(lat1) * Math.sin(lat2) + | |
Math.cos(lat1) * Math.cos(lat2) * Math.cos((latlng2.lng - latlng1.lng) * rad); | |
// 地球半径 | |
return 6371000 * Math.acos(Math.min(a, 1)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment