Geolocating in HTML5 with a single line of code? “It Could Work!”

Some infos about geolocation API from http://dev.w3.org/:

The Geolocation API defines a high-level interface to location information associated only with the device hosting the implementation, such as latitude and longitude. The API itself is agnostic of the underlying location information sources. Common sources of location information include Global Positioning System (GPS) and location inferred from network signals such as IP address, RFID, WiFi and Bluetooth MAC addresses, and GSM/CDMA cell IDs, as well as user input. No guarantee is given that the API returns the device’s actual location.

The API is designed to enable both “one-shot” position requests and repeated position updates, as well as the ability to explicitly query the cached positions. Location information is represented by latitude and longitude coordinates.

And here the code:

 

[embed]https://gist.github.com/andreafortuna/4cf3dd2e2808c9a3d0814e375f6ac03a[/embed]

Obviously, the functions for error and success events could be externally declared for better readability.