HTML and CSS Reference
In-Depth Information
Getting a User's Location
It can be handy to get a user's location when you know that they will need to
enter their current location into the application. This can be useful for finding
and searching for things around them such as events, places, and other people.
The location API is quite simple and makes use of the mobile device's built-in
GPS chip.
To get the location of the user, you can use the following code. It is
asynchronous and nonblocking, so you can continue to process JavaScript
events in the foreground or background while the device searches for the users
var showCurrentPosition = function(position){
alert('Lat: ' + position.coords.longitude + ' Lon: ' +
This is a function that will be called after the mobile device has the position of
the user. The parameter passed back to the callback function is an object that
extends the Coordinates interface and has the properties shown in Table 7-1.
Search WWH ::

Custom Search