Skip to content

Instantly share code, notes, and snippets.

@bkawk
Created April 22, 2017 03:10
Show Gist options
  • Save bkawk/c3ddd67beef5afe794af21a53b660271 to your computer and use it in GitHub Desktop.
Save bkawk/c3ddd67beef5afe794af21a53b660271 to your computer and use it in GitHub Desktop.
Get users Latitude and Longitude
_getPreciseLocation() {
return new Promise((resolve, reject) => {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition((position) => {
if(position){
resolve([position.coords.latitude, position.coords.longitude]);
} else {
reject(Error("We didnt get a location"))
}
});
} else {
reject(Error("Browser doesnt suport geolocation"))
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment