Open In App

HTML DOM Geolocation coords.altitudeAccuracy Property

Last Updated : 23 Nov, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will discuss the Geolocation altitudeAccuracy property. Geolocation in HTML is used to get the geographical position of a user. The getCurrentPosition() method, in this geolocation, returns an object on success.

coords.altitudeAccuracy: This property will return the accuracy position if available in meters above sea level.

Syntax:

coords.altitudeAccuracy 

Example: The following HTML code will return the altitudeAccuracy property.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <meta charset="utf-8">
    <meta name="viewport" 
          content="width=device-width,initial-scale=1">
</head>
  
<body>
    <h2 style="color:green">GeeksforGeeks</h2>
    <p><b> Displaying AltitudeAccuracy</b></p>
  
    <button onclick="getlocation()"> Click Me </button>
    <p id="paraID"></p>
  
    <script>
      var variable1 = document.getElementById("paraID");
  
      function getlocation() {
          navigator.geolocation.getCurrentPosition(showLoc);
      }
  
      function showLoc(pos) {
          variable1.innerHTML = "AltitudeAccuracy: "
                             + pos.coords.altitudeAccuracy;
      }
    </script>
</body>
  
</html>


Output:

Supported Browsers:

  • Google Chrome 5.0
  • Internet Explorer 9.0
  • Firefox 3.5
  • Opera 16.0
  • Safari 5.0

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads