Export (0) Print
Expand All

position object

Provides geographic coordinates and other properties that represent a geographic location.

Internet Explorer 9

Members

The position object has these types of members:

Properties

The position object has these properties.

PropertyDescription

coords

Gets a reference to a coordinates object that contains geographic information returned by the getCurrentPosition or watchPosition functions.

timestamp

Gets the time associated with the geographic information, typically the time the information was received by Internet Explorer.

 

Standards information

There are no standards that apply here.

Remarks

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

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

Examples

The following example shows how to access the position object, which is passed as the position parameter of the successCallback function.


<!DOCTYPE html>  
<html>
<head>
<title>Requesting Location</title>
<script type="text/javascript">
function setText(val, e) {
    document.getElementById(e).value = val;
}
function insertText(val, e) {
    document.getElementById(e).value += val;
}
var nav = null; 
function requestPosition() {
  if (nav == null) {
      nav = window.navigator;
  }
  if (nav != null) {
      var geoloc = nav.geolocation;
      if (geoloc != null) {
          geoloc.getCurrentPosition(successCallback);
      }
      else {
          alert("geolocation not supported");
      }
  }
  else {
      alert("Navigator not found");
  }
}
function successCallback(position)
{
   setText(position.coords.latitude, "latitude");
   setText(position.coords.longitude, "longitude");
}
</script>
</head>
<body>
<label for="latitude">Latitude: </label><input id="latitude" /> <br />
<label for="longitude">Longitude: </label><input id="longitude" /> <br />
<input type="button" onclick="requestPosition()" value="Get Latitude and Longitude"  /> 
</body>
</html>

 

 

Show:
© 2014 Microsoft