How To Get Current User’s Location

How To Get Current User's Location
How To Get Current User’s Location

This simple tutorial on How To Get Current User’s Location based on the Latitude and Longitude coordinates. But in order not to compromise privacy, the user permission is required to access its information.

One of the most important features available in HTML5 webs browser is Geolocation API. The Geolocation is considered the most accurate for devices with GPS.

Let’s Start adding a code.

First, Create an HTML file and add the following code. This code will allow the user to click a Button to Get Current User’s Location.

Next, Add a Javascript code before closing the body tag. This code will simply check the geolocation available. Then using the getCurrentPositon() Method, it will get the current user location of a user.


Finally, Execute the given codes in your browser.

Here’s the full source code used in this application.


If you have any questions or suggestion please feel free to contact me on our contact page.

The recommended article from the author.

Leave a Comment