Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

HTML DOM Geolocation coords.altitude Property

  • Last Updated : 23 Nov, 2021

In this article, we will discuss the Geolocation altitude 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.altitude: This property will return the altitude in meters above the sea level.




Example: The following HTML code will return the altitude.


<!DOCTYPE html>
    <meta charset="utf-8">
    <meta name="viewport" 
    <h2 style="color:green">GeeksforGeeks</h2>
    <p><b> Displaying Altitude</b></p>
    <button onclick="getlocation()"> Click Me </button>
    <p id="paraID"></p>
       var variable1 = document.getElementById("paraID");
        function getlocation() {
        function showLoc(pos) {
            variable1.innerHTML = "Altitude: " 
              + pos.coords.altitude;


Supported Browsers:

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

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!