Collapse the table of content
Expand the table of content

position object

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


The position object has these types of members:


The position object has these properties.



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


Gets the time associated with the geographic information, typically the time the information was received by a Windows Store app using JavaScript.


Standards information

There are no standards that apply here.


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

The position object is only supported for webpages displayed in a Windows Store app using JavaScript. For more information, see Defining Document Compatibility.


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

<!DOCTYPE html>  
<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) {
      else {
          console.log("geolocation not supported");
  else {
      console.log("Navigator not found");
function successCallback(position)
   setText(position.coords.latitude, "latitude");
   setText(position.coords.longitude, "longitude");
<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"  /> 



© 2016 Microsoft