function location() {
var geo = false;
navigator.geolocation.getCurrentPosition(
function(position){
geo = {lat: position.coords.latitude, lng: position.coords.longitude};
}
);
return geo;
}
function location() {
return new Promise(function(resolve, reject) {
navigator.geolocation.getCurrentPosition(resolve, reject);
});
}
location()
.then(function(position) {
console.log({
lat: position.coords.latitude,
lng: position.coords.longitude
});
})
.catch(function(error) {
console.log(error);
});