-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
jQuery Mobile Cookbook
By :
The Geolocation API is a separate specification and is part of the HTML5 stack. You can use JavaScript and locate the client device location using various techniques, such as IP address, Wi-Fi, GSM/CDMA cell IDs, or device Global Positioning System (GPS). This recipe shows you how to find the current location using the Geolocation API in your app.
Copy the full code of this recipe from the code/11/geolocation folder. You can launch this code using the URL: http://localhost:8080/11/geolocation/main.html.
The steps to be followed are:
Create main.html with an empty div tag to display the geolocation information.
<div data-role='content'> <p>You current Position is ...</p> <div id='geopos'></div> </div>
Invoke the getCurrentPosition() method to obtain the current location using a show_pos() callback function.
$('#main').live('pageinit', function(event) {
if (navigator.geolocation...
Change the font size
Change margin width
Change background colour