Horje

Example of HTML Geolocation API

Try following Example
index.html
Example: HTML

<!DOCTYPE html>
<html>
 
<body>
    <p>Displaying location using Latitude and Longitude</p>
 
    <button class="geeks" onclick="getlocation()">
        Click Me
    </button>
    <p id="demo1"></p>
 
    <script>
        let variable1 = document.getElementById("demo1");
        function getlocation() {
            navigator.geolocation.getCurrentPosition(showLoc);
        }
        function showLoc(pos) {
            variable1.innerHTML =
                "Latitude: " +
                pos.coords.latitude +
                "<br>Longitude: " +
                pos.coords.longitude;
        }
    </script>
</body>
   
</html>




Single Articles
Example of HTML Geolocation APIHTML Geolocation API


Related Articles
What is HTML Geolocation API HTML Geolocation API
How to create HTML Locate the User's Position HTML Geolocation API
What type of browsers will support for HTML Geo Location HTML Geolocation API
How to Use HTML Geolocation HTML Geolocation API
How to add Handling Errors and Rejections HTML Geolocation API
What is Location-specific Information HTML Geolocation API
How to create HTML getCurrentPosition() Method - Return Data HTML Geolocation API
How to create HTML Geolocation Object - Other interesting Methods HTML Geolocation API

Type:
Html
Category:
Web Tutorial
Sub Category:
HTML Geolocation API
Uploaded by:
Admin