tags:

views:

49

answers:

3

Hi! I would like to know. How geolocation on web browser work?

I access to this web site

http://html5demos.com/geo

and when I allow that browser to detect location. it show me current location.

but when i send that url to my friends to test it. some one tell me it work, but someone else.

How geolocation work and how implement it to get correct location?

+2  A: 

When you visit a location-aware website, Firefox will ask you if you want to share your location.

If you consent, Firefox gathers information about nearby wireless access points and your computer’s IP address. Then Firefox sends this information to the default geolocation service provider, Google Location Services, to get an estimate of your location. That location estimate is then shared with the requesting website.

http://www.mozilla.com/en-US/firefox/geolocation/

So it depends on the browser they are using and some luck :-)

BarsMonster
A: 

Re how it works: the Wikipedia article discusses several techniques (IP address location, cellphone and WiFi triangulation, GPS).

The HTML5 implementations require both browser support (FF 3.6, Opera 10.60, Chrome 4? 5?, IE maybe some day) and user consent before the geolocation data are retrieved.

As to how to implement it, the code of the demo you link to seems to be under the MIT License which basically says "you can do whatever, as long as you keep the resulting code under the license"; so you could take that code as a base to build on.

Piskvor
A: 

Things really depend on the implementation of the website you are using and your browser.

Simplest way, which doesnt require any client side extensions is that the webpage gets your ip address and uses any of the "ip to geolocation" services to make a questimate where you are currently.

Second options is that browsers have an extension that can advertise your your coordinates to the webserver. In these cases, this information in the client side can be either fetched, again from ip to geolocation services or gps unit attached to your computer. For example, Nokia N900 and build-in browser MicroB has this sort of extension.

rasjani