HTML and CSS Reference
In-Depth Information
The success callback is passed a position object that contains a coordinates object and
a timestamp. The coordinates object contains the following:
latitude , which is specified in decimal degrees
longitude , which is specified in decimal degrees
altitude , which is specified in meters above the ellipsoid
accuracy , which is specified in meters
altitudeAccuracy , which is specified in meters
heading , which is the direction of travel specified in degrees
speed , which is specified in meters per second
Of those seven, only three are guaranteed to be there: latitude , longitude , and
accuracy .
For the solution, take the latitude and longitude and append them to the body of the
web page using jQuery:
function printLatLong(lat, long) {
$('body').append('<p>Lat: ' + lat + '</p>');
$('body').append('<p>Long: ' + long + '</p>');
See Also
The W3C Geolocation specification at .
8.2 Getting Basic Geolocation Data with a Fallback
You want to determine a user's Internet location when that user's browser does not
support the HTML5 Geolocation API natively.
Perform an IP-to-location lookup as a fallback. It's certainly not as accurate as latitude
and longitude coordinates, but it's far better than not having any location data at all.
Google versus MaxMind
Google offers the google.loader.ClientLocation object in its Google Maps API v3
library, but it does not work for many US IP addresses.
The MaxMind GeoIP JavaScript Web Service seems more accurate and up-to-date.
Also, it's free as long as you link back to the website. Alter-
natively, MaxMind offers a JavaScript attribution-free license that can be purchased
for $250/year.
Search WWH ::

Custom Search