Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there a good PHP geolocation service? [closed]

i am looking for a good PHP geolocation service, so when i start my app i can have something like:

<?php
$service = new GeoLocService();
echo $service->getLat();
echo $service->getLng();
?>

to retrieve the position of the user in latitude and logitude values.

like image 855
Raul Leaño Martinet Avatar asked Jan 18 '11 14:01

Raul Leaño Martinet


3 Answers

Geo-location would need to be done in the browser, since the server (ie PHP) would never get to find out most of the relevant data. The main API for doing geolocation in the browser is Google's, but you as a developer wouldn't need to use that API; you'd use the browser's API, which is standardised (though only supported in a few browsers so far).

The most useful information you'll get for locating a user at the server end would be their IP address, which is often sufficient to locate them down to the nearest town. There are IP-to-nation and IP-to-location databases and APIs which you can download to help with this. Some are free, but to get the town-level locations, you'll be paying for the service. Whichever you go with, they do need to be kept up-to-date though, because IP ranges are often re-allocated.

The browser-level APIs work by having the browser scan the area for Wi-Fi access points. It sends the list of access points to Google, who then use that to work out the Lat/Long (often with alarmingly accurate results).

How do they do that? You may remember Google getting into trouble recently for sucking data from people's Wi-Fis? What they were actually trying to do was map the world's Wi-Fi access points for this geolocation feature.

It does, of course, require the client to have Wi-Fi enabled.

Note that your browser doesn't give direct access to this list of access points to the client (ie Javascript or the DOM), so you can't post it to PHP to get the location using this method via the server; it would have to be done at the client-end.

like image 130
Spudley Avatar answered Oct 02 '22 19:10

Spudley


MaxMind PHP API isn't bad... http://www.maxmind.com/app/php

like image 26
kieran Avatar answered Oct 02 '22 19:10

kieran


Read the following docs on Geo-Loacaion API: http://dev.w3.org/geo/api/spec-source-v2.html

I'm sure that the above docs will be very useful for you.

like image 23
Manish Trivedi Avatar answered Oct 02 '22 17:10

Manish Trivedi