• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 469
  • Last Modified:

Geolocation using PHP or HTML 5 location services?

I need to implement geolocation in a PHP-based app that I'm developing, and I'd like to know what the best way to go about it is.  

Based on what I've researched so far, .. doing a lookup based on IP address (using an API) is not always 100% accurate, .. and some lookup service providers are more reliable than others. Also, .. you're generally only able to identify the Country of the visitor, .. and not the precise location (ie: US State / City).  So .. I'm wondering if there might be a better way?

Does anyone here have any suggestions as to what the best way to implement something like this would be?  I'm looking for the most accurate and precise geolocation method possible (preferably something that identifies more than just the Country), .. and if it means that we have to subscribe to and pay for some service, .. that's ok.  

What about HTML 5's location services?  Is  there any way that I can leverage that?  

Any tips or advice (or code samples) would be greatly appreciated.

Thanks!
- Yvan






0
egoselfaxis
Asked:
egoselfaxis
2 Solutions
 
Ray PaseurCommented:
Have not used HTML5.  I have used GEOIO with great success.  Free for low-level use, modest charge for high-level use.  Example of a map drawn from a data base of GEOIO responses is here:
http://www.landonbaseball.com/site_visitors.php

In that map I intentionally limit the geocode information to DECIMAL(8,4) with a UNIQUE index on lat, lon columns to keep the map from becoming cluttered.  Greater accuracy - right to the rooftop - is achieved with DECIMAL(10,6).

GEOIO is here.  Get an API key and you can start testing within seconds.
http://www.geoio.com/

In my app I decoupled the GEOIO part from the rest of the web site.  I get the client's IP address and POST a script that uses GEOIO information to update my data base.  I do not wait for the POST to complete and I do not care if the GEOIO service fails or rejects my request.  YMMV on this point!
0
 
Mohamed AbowardaSoftware EngineerCommented:
This artical is helpful:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/PHP_Databases/A_3437-IP-Address-to-Country-in-PHP.html

You might also consider subscribing with a company that provide this service so you can get the updates.
0
 
Marco GasiFreelancerCommented:
You can find simple free service here: http://ipinfodb.com/index.php. Once you are registered, you get a free key to use in very simple code

For city:

http://api.ipinfodb.com/v3/ip-city/?key=<your_api_key>&ip=74.125.45.100

For country:

http://api.ipinfodb.com/v3/ip-country/?key=<your_api_key>&ip=74.125.45.100

Here http://ipinfodb.com/ip_location_api.php you find a little script to get data and echo them ina page.

Cheers
0
 
egoselfaxisAuthor Commented:
Thanks guys!  This is exactly what I was looking for.

- Yvan
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now