---
title: "getCurrentPosition method in HTML5"  
description: "Gelocation is the identification of the real world geographic location of an internet-connected computer, mobile device, website visitor or other. IP"  
author: "Anonymous User"  
published: 2011-07-30  
updated: 2020-08-08  
canonical: https://www.mindstick.com/articles/592/getcurrentposition-method-in-html5  
category: "jquery"  
tags: ["jquery"]  
reading_time: 2 minutes  

---

# getCurrentPosition method in HTML5

Gelocation is the identification of the real world geographic location of an internet-connected computer, mobile device, website visitor or other. IP address geolocation data can include information such as country, region, and city, postal/zip code, latitude, longitude and time zone..... Today most of the browsers and mobile devices support Geolocation API. The geolocation APIs work with a new property of the global navigator object i.e. Geolocation object which can be created as follows:\

var location = navigator.geolocation;

##### Gelocation method:

- getCurrentPosition()
- watchposition()
- clearWatch()

The getCurrentPosition method retrieves the current geographic location of the user. The location information is returned in a position object. In this article I am trying to show you that how we can find out the user geographic location.

##### Code:

```
<script type="text/javascript">         function Location(position)//location function is defining with parameter         {            var latitude = position.coords.latitude;  //Specifies the longitude estimate in decimal degrees. The value range is [-180.00, +180.00].            var longitude = position.coords.longitude;            document.getElementById("lati").innerHTML = latitude; //latitude value is defining in label element where id is lati            document.getElementById("longi").innerHTML = longitude;         }         function findLocation()          {            if (navigator.geolocation)//checking browser compatibility             {                navigator.geolocation.getCurrentPosition(Location);//getCurrentPosition method retrieve the current geographic location of the user               }         }     </script></head><html><body>    Latitude:<label id="lati"></label><br /><br />    Longitude:<label id="longi"></label><br /><br />     <input type="submit" onclick="findLocation();" value="Find Location" /></body>
```

When button is clicked latitude and longituudeof the user will show on page as shown below:

![getCurrentPosition method in HTML5](https://www.mindstick.com/mindstickarticle/5013acba-e863-4e75-b890-fdacffc368c3/images/7484c665-5188-4fba-ae46-63ebefbc38ad.png)

\

---

Original Source: https://www.mindstick.com/articles/592/getcurrentposition-method-in-html5

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
