Created
April 6, 2015 20:22
-
-
Save tmountain/cc7e8a2a0eb861fe9e1e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 arePointsNear(checkPoint, centerPoint, km) { | |
var ky = 40000 / 360; | |
var kx = Math.cos(Math.PI * centerPoint.lat / 180.0) * ky; | |
var dx = Math.abs(centerPoint.lng - checkPoint.lng) * kx; | |
var dy = Math.abs(centerPoint.lat - checkPoint.lat) * ky; | |
return Math.sqrt(dx * dx + dy * dy) <= km; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment