In this recipe, we will use the geolocation specification and geo.js
to display the current location of an active user on a map, and show their current latitude and longitude.
Visit http://code.google.com/p/geo-location-javascript/ to download the latest version of geo.js
, or grab the link URL from the wiki (http://code.google.com/p/geo-location-javascript/wiki/JavaScriptAPI) to link to it directly online.
First, we will create HTML5 opening page tags:<head></head>.
Then, in the meta tag, we will set the name attribute to "viewport", and define the following values for the content attribute: width = device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=no
;
Now, declare a script tag with the src attribute of: http://code.google.com/apis/gears/gears_init.js
Then, call the geo.js
script: src="js/geo.js"
.
The code block should look like the following so far:
<html><head>...