Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

geolocation in javascript

geolocationSupported();

function geolocationSupported() {
  if (navigator.geolocation) {
    console.log("Geolocation is supported by this browser :)");
    getCurrentLocation();
  } else {
    console.log("Geolocation is NOT supported by this browser :(");
  }
}

function getCurrentLocation() {
  navigator.geolocation.getCurrentPosition(function(result) {
    result.coords.latitude; // latitude value
    result.coords.longitude; // longitude value
  });
}
Source by openjavascript.info #
 
PREVIOUS NEXT
Tagged: #geolocation #javascript
ADD COMMENT
Topic
Name
4+7 =