Welcome Guest! (App Version 3.1)

websitnero logo name

Geolocation

Geolocation API Support in HTML5

Geolocation helps in getting the co-ordinates of the device of the end user. Using this feature apps can get the exact location of the user and thereby use this information for various purposes. For example, it may be helpful in a mobile app where user wants to find best food restaurants within 8 miles to his current location. There might be a scenario where an application might ask a user to share his location to deliver him some stuff that he ordered before. There can be many scenarios, but undoubtedly geolocation is another good tool for HTML programmers.

Example

<button onclick="getMyLocation()">Click Me</button>
<p id="para1"></p>

<script>

  function getMyLocation() {
    navigator.geolocation.getCurrentPosition(showPosition);
  }

  function showPosition(position) {
    var latitude =  position.coords.latitude;
    var longitude = position.coords.longitude;
    x = document.getElementById("para1");
    x.innerHTML = "Latitude is:" + latitude + " Longitude is:" + longitude; 
  }

</script>
WebsiteNero is highly optimized for learning various website developing technlogies. We try our best to add maximum modules and examples to help learn the concepts clearly and vividly. We try to present all content and examples as simple as we can removing any complexity to hurdle easy understanding. We try best provide you with worthful content, but we cannot guarantee full correctness of all the content on this site. While using this website, you agree to have read and accepted all our terms of use and conditions, cookie, and privacy policy. Copyright, 2013-2018 by websitenero.com. All Rights Reserved.