Last active
February 28, 2019 03:09
-
-
Save armanhakimsagar/dfb4f002ff5cbccd9358f982eb03170d 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
| Keywords: | |
| google map radius search | |
| Radius/nearest results | |
| tutorials: | |
| https://www.youtube.com/watch?v=szAVI-YvbmQ (distance lat | lon) | |
| https://stackoverflow.com/questions/10053358/measuring-the-distance-between-two-coordinates-in-php (get distance between lat long) | |
| https://www.youtube.com/watch?v=dWn9iBYiJrk | |
| tools: | |
| angular google map package | |
| geofire | |
| https://www.youtube.com/watch?v=qS3BEYIDrGU | |
| https://stackoverflow.com/questions/5755905/radius-nearest-results-google-maps-api | |
| http://jsfiddle.net/kjy112/3feUC/ | |
| https://www.youtube.com/watch?v=5oG2Q2GMOBE | |
| https://developers.google.com/maps/documentation/javascript/geometry?hl=el#Distance | |
| __________________________________ | |
| main function : | |
| function distance($lat1, $lon1, $lat2, $lon2, $unit) { | |
| $theta = $lon1 - $lon2; | |
| $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta)); | |
| $dist = acos($dist); | |
| $dist = rad2deg($dist); | |
| $miles = $dist * 60 * 1.1515; | |
| $unit = strtoupper($unit); | |
| if ($unit == "K") { | |
| return ($miles * 1.609344); | |
| } else if ($unit == "N") { | |
| return ($miles * 0.8684); | |
| } else { | |
| return $miles; | |
| } | |
| } | |
| echo distance(32.9697, -96.80322, 29.46786, -98.53506, "M") . " Miles<br>"; | |
| echo distance(32.9697, -96.80322, 29.46786, -98.53506, "K") . " Kilometers<br>"; | |
| echo distance(32.9697, -96.80322, 29.46786, -98.53506, "N") . " Nautical Miles<br>"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment