coords property

Gets a reference to an IWebGeocoordinates object that contains geographic information returned by the IWebGeolocation::getCurrentPosition or IWebGeolocation::watchPosition functions.

 

Syntax

HRESULT value = object.get_coords(IWebGeocoordinates** p);

Property values

Type: Object

A reference to the an IWebGeocoordinates object representing the geographic location, including latitude, longitude, and accuracy of the location data.

Standards information

Remarks

The position is passed as a parameter to the callback function defined with the IWebGeolocation::getCurrentPosition function or the IWebGeolocation::watchPosition function.

Windows Internet Explorer 9. This property is supported only 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 in the successCallback function. In this example, this object is named position.

<!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>