This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

PositionOptions

Summary

A native script object used by the getCurrentPosition() and watchPosition() methods.

Properties

enableHighAccuracy
A request from the application to receive the best possible location results. The intended purpose of this attribute is to allow applications to inform the implementation that they do not require high accuracy geolocation fixes so the implementation can avoid using geolocation providers that consume a significant amount of power (e.g., GPS).
maximumAge
Indicates that the application is willing to accept a cached position whose age is no greater than the specified time (in milliseconds).
timeout
Denotes the maximum length of time (expressed in milliseconds) that is allowed to pass from the call to getCurrentPosition() or watchPosition() until the corresponding successCallback is invoked.

Methods

No methods.

Events

No events.

Examples

Obtain user position using high accuracy and a timeout if a location cant be found within 60 seconds.

navigator.geolocation.getCurrentPosition(geoSuccess,geoError, {'enableHighAccuracy':true,'timeout':60000,'maximumAge':0});

/* Position found*/
function geoSuccess(position)
{
alert('latitude: '+position.coords.latitude+' AND longitude: '+position.coords.longitude);
}

/* Position not found*/
function geoError(position)
{
alert("No position found");
}

Related specifications

W3C Geolocation Specification
W3C Editor’s Draft

Attributions

  • This article contains content originally from external sources, including ones licensed under the CC-BY-SA license. cc-by-sa-small-wpd.png

  • Portions of this content copyright 2012 Mozilla Contributors. This article contains work licensed under the Creative Commons Attribution-Sharealike License v2.5 or later. The original work is available at Mozilla Developer Network: Article

  • Microsoft Developer Network: Windows Internet Explorer API reference Article