How does HTML 5 Geolocation work?

I know that many people asked this question, but I don’t think I found the right answer. My question is when you run the HTML 5 Geolocation API on the desktop in firefox and you click on the common place where it takes your IP address, but how does it know which wireless points it needs to use in order to find its distance? I run the application at home, and I get an accuracy of 50 m, but I go next door to my neighbor who has the same Internet provider, and on my desktop I get an accuracy of 18 km back? So, if someone can explain this to me or tell me where to read this information, would it be very helpful?

thank

+5
source share
3 answers

The W3C Geolocation API is built on existing technologies and is heavily dependent on the Google Gears Geolocation API. In fact, the implementation of Firefox Geolocation uses the Google Network Location Provider.

Google Gears Geolocation , , , , , Google (code.l.google.com). - , Wi-Fi . JSON HTTP POST. .

" , (Google) Wi-Fi, , Wi-Fi . , Firefox, Firefox -. , (google) , ( google) IP-, . , , ".

: http://www.google.com/intl/en/privacy/lsf.html http://en.wikipedia.org/wiki/W3C_Geolocation_API

+1

API -. JavaScript , , , - , .

getCurrentPosition()? , . , . . Mozilla Firefox getCurrentPosition() API , "" .

getCurrentPosition() , , . , : coords timestamp. - , , . ( , , . , , . GPS GPS ..) coords , , : .

, : http://diveintohtml5.ep.io/geolocation.html

0

API HTML5 , (GPS), IP- , , . , API , , .

- HTML5 Geolocation (http://html5demos.com/geo). , - , API, , API .

API :

  • getCurrentPosition (successCallback, errorCallback, options)

    .

  • watchPosition (successCallback, errorCallback, options)

    watchId successCallback . (, GPS ).

  • clearWatch (watchId)

    watchPosition() watchId.

:

if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(userPositionSuccess, userPositionError);
} else {
  alert("Your browser does not support geolocation.");
}

function userPositionSuccess(position) {
  alert("Latitude: " + position.coords.latitude + " Longitude: " + position.coords.longitude);
}

function userPositionError() {
  alert("There was an error retrieving your location!");
}
0

All Articles