Search code examples
phpgoogle-mapsgeotagging

PHP / Google Maps - Geofence


I am attempting to create a simple tracker using php and google maps. Right now I have the tracker working but I want it to detect proximity to certain markers. For example if the user is within 30m of the my "house" (a marker) the script will update it's status saying it is at "so and so's house". I would like this to be achievable in PHP. Would the best method be to detect the long / lat of each marker and create a simple perimeter around it, then detect if the users long and lat places within that perimeter. Are there examples of this around that I could possibly work from or mathematical equations.


Solution

  • The Haversine formula is what you're looking for. There's an article on Google Code that describes how to use it with MySQL and PHP.