Forum Moderators: phranque

Message Too Old, No Replies

Get user's location

         

ocon

4:10 pm on May 3, 2010 (gmt 0)

10+ Year Member Top Contributors Of The Month



How can a website get the user's coordinates?

I know it's possible, from sites like Google Maps, and I also know that the users have to allow the website to get such information.

Is there some code, maybe a php script, that I can insert into the page?

Would this work on the mobile browsers, such as on the iPhone?

Thanks

lammert

5:13 pm on May 3, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You can get a good estimation of the user location with a database which contains IP address ranges and the corresponding locations. These Geo-location databases are available on country level, but also on state and city level. More accurate location determination requires a larger database. Some of these databases are free to use, others are paid for.

Mobile phones often very accurately know their own position. Some have GPS on board, others can determine the location based on triangulation of the signals of different antennas. This position information can however not be made available to your site through a mobile browser, only through an applet running on that mobile phone.

encyclo

5:33 pm on May 3, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can look into some of the "Location-aware Browsing" features of the latest browsers, where you can offer wifi users the possibility to share their location (requires explicit consent from the user). Here's some information for Firefox:

  • Location-Aware Browsing in Firefox [mozilla.com]
  • Using geolocation (Mozilla developer center [developer.mozilla.org]

    See also the Google Geolocation API [code.google.com] (see Google's usage [googlemobile.blogspot.com] of the API).
  • ocon

    8:05 pm on May 4, 2010 (gmt 0)

    10+ Year Member Top Contributors Of The Month



    Thank you very much, the navigator.geolocation function discussed in the Mozilla developer center was exactly what I was looking for.