Skip to content

Instantly share code, notes, and snippets.

@nickihastings
Created February 6, 2018 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickihastings/58d15a5790c0cc142479a76c9525758c to your computer and use it in GitHub Desktop.
Save nickihastings/58d15a5790c0cc142479a76c9525758c to your computer and use it in GitHub Desktop.
Javascript function to get the latitude and longitude gelocation info from the browser.
$(document).ready(function(){
var latitude = '';
var longitude = '';
navigator.geolocation.getCurrentPosition(function(position) {
latitude = position.coords.latitude;
longitude = position.coords.longitude;
console.log('lat=' + latitude + ' long=' + longitude);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment