This repository has been archived by the owner on Apr 18, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
111 additions
and
19 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,53 @@ | ||
function CompassHeading(magneticHeading, trueHeading, headingAccuracy, timestamp) { | ||
function CompassHeading(magneticHeading, trueHeading, headingAccuracy) { | ||
this.magneticHeading = magneticHeading; | ||
this.trueHeading = trueHeading; | ||
this.headingAccuracy = headingAccuracy; | ||
this.timestamp = timestamp; | ||
this.timestamp = new Date(); | ||
} | ||
|
||
navigator.compass = { | ||
getCurrentHeading: function(compassSuccess, compassError, compassOptions) { | ||
if(deviceapis.orientation == undefined) { | ||
console.log("navigator.compass.getCurrentHeading", "Operation not supported!") | ||
return -1; | ||
} | ||
var success = function(orientation) { | ||
var compassHeading = new CompassHeading(orientation.alpha); | ||
var compassHeading = new CompassHeading(orientation.alpha, orientation.alpha, 0); | ||
compassSuccess(compassHeading); | ||
}; | ||
var error = function(orientation) { | ||
|
||
var error = function(error) { | ||
compassError(error); | ||
}; | ||
if(deviceapis.orientation) { | ||
deviceapis.orientation.getCurrentOrientation(success); | ||
} else { | ||
console.log("navigator.compass.getCurrentHeading", "Orientation not supported!"); | ||
} | ||
deviceapis.orientation.getCurrentOrientation(success, error); | ||
}, | ||
watchHeading: function() { | ||
watchHeading: function(compassSuccess, compassError, compassOptions) { | ||
if(deviceapis.orientation == undefined) { | ||
console.log("navigator.compass.watchHeading", "Operation not supported!") | ||
return -1; | ||
} | ||
var success = function(orientation) { | ||
var compassHeading = new CompassHeading(orientation.alpha, orientation.alpha, 0); | ||
compassSuccess(compassHeading); | ||
}; | ||
var error = function(error) { | ||
compassError(error); | ||
}; | ||
var orientationOptions = null; | ||
|
||
if (compassOptions != undefined) { | ||
orientationOptions = { | ||
minNotificationInterval: compassOptions.frequency || 100 | ||
}; | ||
} | ||
return deviceapis.orientation.watchOrientation(success, error, orientationOptions); | ||
}, | ||
clearWatch : function() { | ||
|
||
clearWatch : function(watchID) { | ||
deviceapis.orientation.clearWatch(watchID); | ||
}, | ||
watchHeadingFilter: function() { | ||
|
||
console.log("navigator.compass.watchHeadingFilter", "Operation not supported!"); | ||
}, | ||
clearWatchFilter: function() { | ||
|
||
console.log("navigator.compass.clearWatchFilter", "Operation not supported!"); | ||
} | ||
} |
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