Skip to content

Instantly share code, notes, and snippets.

@salmanyaqoob
Created March 29, 2021 07:46
Show Gist options
  • Select an option

  • Save salmanyaqoob/8cb68fa5e926edc3f23801111fa3a8df to your computer and use it in GitHub Desktop.

Select an option

Save salmanyaqoob/8cb68fa5e926edc3f23801111fa3a8df to your computer and use it in GitHub Desktop.
initLocationCompass(){
var _this = this;
this.locationLoading().then(result => {
console.info("Location: " + result);
_this.loadCompass(result);
_this.isLocationLoading = false;
_this.isLocationError = false;
}, error => {
console.info("Location: error ->" + error);
_this.isLocationLoading = false;
_this.isLocationError = true;
});
},
locationLoading() {
return new Promise(function (resolve, reject) {
return geolocation.getLocation({
success: function (data) {
console.log('success get location data. latitude:' + data.latitude + 'long:' + data.longitude);
return resolve({
latitude: data.latitude,
longitude: data.longitude
});
},
fail: function (data, code) {
console.log('fail to get location. code:' + code + ', data:' + data);
return reject({
error: 'fail to get location. code:' + code + ', data:' + data
});
},
});
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment