Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

coords property

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

Geolocation API Specification, Section 5.3Internet Explorer 9

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>

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.