forked from cory/tildefriends
Oh. Device orientation is separate from location.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3295 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -1,19 +1,41 @@
|
||||
"use strict";
|
||||
|
||||
core.register("geolocation", function(event) {
|
||||
terminal.print("hi");
|
||||
let gPosition = null;
|
||||
let gOrientation = null;
|
||||
let gError = null;
|
||||
|
||||
function draw() {
|
||||
terminal.cork();
|
||||
if (event.position) {
|
||||
for (let field in event.position.coords) {
|
||||
let value = event.position.coords[field];
|
||||
terminal.clear();
|
||||
if (gPosition) {
|
||||
for (let field in gPosition.coords) {
|
||||
let value = gPosition.coords[field];
|
||||
terminal.print(field, ": ", value != null ? value.toString() : "null");
|
||||
}
|
||||
} else if (event.error) {
|
||||
}
|
||||
if (gOrientation && gOrientation.alpha && gOrientation.beta && gOrientation.gamma) {
|
||||
terminal.print(gOrientation.alpha.toString(), ", ", gOrientation.beta.toString(), ", ", gOrientation.gamma.toString(), ", ", gOrientation.absolute.toString());
|
||||
}
|
||||
if (gError) {
|
||||
terminal.print(event.error.message);
|
||||
terminal.clearWatch();
|
||||
}
|
||||
terminal.uncork();
|
||||
}
|
||||
|
||||
core.register("geolocation", function(event) {
|
||||
if (event.position) {
|
||||
gPosition = event.position;
|
||||
} else if (event.error) {
|
||||
gError = event.error;
|
||||
}
|
||||
draw();
|
||||
});
|
||||
|
||||
core.register("deviceorientation", function(event) {
|
||||
gOrientation = event.orientation;
|
||||
draw();
|
||||
});
|
||||
|
||||
terminal.watchPosition({enableHighAccuracy: true});
|
||||
//terminal.watchPosition();
|
||||
terminal.setSendDeviceOrientationEvents(true);
|
Reference in New Issue
Block a user