Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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