HTML Geolocation

You are Here:

HTML Geolocation

The HTML Geolocation is used to get the geographical location information for a client-side device.

Note: For privacy reasons, the user is asked for permission to report location information.

In the following example, the getCurrentPosition() method return the user's current position.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <p>Html Geolocation will help you finding your users Location.</p> <button onclick="getMyLocation()">Click To Your Location</button> <p id="point"></p> <script> var x = document.getElementById("point"); function getMyLocation(){ if(navigator.geolocation) navigator.geolocation.getCurrentPosition(showPosition); else x.innerHTML = "Geolocation is not supported by this browser."; } function showPosition(position) { x.innerHTML = "Latitude: " + position.coords.latitude + "<br>Longitude: " + position.coords.longitude; } </script> </body> </html>

Reminder

Hi Developers, we almost covered 99.5% of HTML Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in HTML.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author