Skip to content

Instantly share code, notes, and snippets.

@lucasdu4rte
Created May 4, 2018 18:53
Show Gist options
  • Select an option

  • Save lucasdu4rte/dfbcb77aecfbda81d2746274b7811b06 to your computer and use it in GitHub Desktop.

Select an option

Save lucasdu4rte/dfbcb77aecfbda81d2746274b7811b06 to your computer and use it in GitHub Desktop.
function getLocation(cbSuccess, cbError) {
if (navigator.geolocation) {
return navigator
.geolocation
.getCurrentPosition(cbSuccess, cbError);
} else {
// Browser doesn't support Geolocation
return 'Browser doesnt support Geolocation'
}
}
function geoSuccess(position) {
let lat = position.coords.latitude;
let lng = position.coords.longitude;
this.setState({
geolocation: {
latitude: lat,
longitude: lng
}
})
}
function geoError(error) {
console.log(error);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment