Created
April 22, 2017 03:10
-
-
Save bkawk/c3ddd67beef5afe794af21a53b660271 to your computer and use it in GitHub Desktop.
Get users Latitude and Longitude
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_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