This topic has not yet been rated - Rate this topic

positionError object

[This documentation is preliminary and is subject to change.]

Provides methods for obtaining information about an error that occurred while attempting to use the Geolocation API.

Internet Explorer 9

Standards information

There are no standards that apply here.

Remarks

The positionError object is passed as a parameter to the error callback function defined for the getCurrentPosition function and the watchPosition function.

Windows Internet Explorer 9. The geolocation object is only supported for webpages displayed in IE9 Standards mode. For more information, see Defining Document Compatibility.

Examples

The following example shows an error callback function. The object passed into the error parameter is a positionError object.


function errorCallback(error) {
    var message = "";   
    // Check for known errors
    switch (error.code) {
        case error.PERMISSION_DENIED:
            message = "This website does not have permission to use " + 
                      "the Geolocation API";
            break;
        case error.POSITION_UNAVAILABLE:
            message = "The current position could not be determined.";
            break;
        case error.PERMISSION_DENIED_TIMEOUT:
            message = "The current position could not be determined " + 
                      "within the specified timeout period.";            
            break;
    }
    // If it's an unknown error, build a message that includes 
    // information that helps identify the situation, so that 
    // the error handler can be updated.
    if (message == "")
    {
        var strErrorCode = error.code.toString();
        message = "The position could not be determined due to " + 
                  "an unknown error (Code: " + strErrorCode + ").";
    }
    console.log(message);
}

 

 

Build date: 2/14/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ