Created
March 29, 2021 07:47
-
-
Save salmanyaqoob/39971c5bbc79b4175ef55cfa98d16835 to your computer and use it in GitHub Desktop.
This file contains 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
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