HTML and CSS Reference
In-Depth Information
Figure 7-2. Location request
This presents a problem, as you should expect that some users might not wish
to share their current location and might tap the decline button; or there could
simply be an issue with retrieving the current location of the user. This can be
handled with an error event handler, which is the second parameter of the
getCurrentPosition() method. In order to handle errors in retrieving the user's
current location, you must create an error handler, which will accept the error
object.
var handleLocationError = function(error){
alert(error.message);
}
navigator.geolocation.getCurrentPosition(showCurrentPosition,
handleLocationError);
The error object is part of the PositionError interface, and has the properties
shown in Table 7-2.
Search WWH ::




Custom Search