Syntax error Error codes returned in the PositionError object HTML5 Geolocation

Error codes returned in the PositionError object HTML5 Geolocation



The following table describes the possible error codes returned in the PositionError object:

Code
Constant
Description
0
UNKNOWN_ERROR
The method failed to retrieve the location of the device due to an unknown error.
1
PERMISSION_DENIED
The method failed to retrieve the location of the device because the application does not have permission to use the Location Service.
2
POSITION_UNAVAILABLE
The location of the device could not be determined.
3
TIMEOUT
The method was unable to retrieve the location information within the specified maximum timeout interval.

Following is a sample code, which makes use of the PositionError object. Here errorHandler method is a callback method:

function errorHandler( err ) {
   if (err.code == 1) {
      // access is denied
   }
...
}
Updated on: 2020-01-28T08:27:49+05:30

411 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements