Skip to content

Instantly share code, notes, and snippets.

@salmanyaqoob
Created March 29, 2021 07:47
Show Gist options
  • Save salmanyaqoob/39971c5bbc79b4175ef55cfa98d16835 to your computer and use it in GitHub Desktop.
Save salmanyaqoob/39971c5bbc79b4175ef55cfa98d16835 to your computer and use it in GitHub Desktop.
loadCompass(coordinates = {
latitude: 24.7136,
longitude: 46.6753
}) {
var _this = this;
var qiblaDirection = parseFloat(this.qibla(coordinates));
console.log("compass: qiblaDirection: " + qiblaDirection);
_this.needle_transform = "rotate(" + qiblaDirection + "deg)";
sensor.subscribeCompass({
success: function (ret) {
var direction = ret.direction;
var compassDirection = (360 - direction);
_this.compass_transform = "rotate(" + compassDirection + "deg)";
console.log("compass: compassDirection: " + direction);
},
fail: function (data, code) {
console.error('compass: subscribe compass fail, code: ' + code + ', data: ' + data);
},
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment