Private device orientation property enum

This commit is contained in:
Tim Schaub
2016-12-27 13:17:58 -07:00
parent b901e57288
commit d6e311c9ba

View File

@@ -75,7 +75,7 @@ ol.DeviceOrientation = function(opt_options) {
this.listenerKey_ = null; this.listenerKey_ = null;
ol.events.listen(this, ol.events.listen(this,
ol.Object.getChangeEventType(ol.DeviceOrientation.Property.TRACKING), ol.Object.getChangeEventType(ol.DeviceOrientation.Property_.TRACKING),
this.handleTrackingChanged_, this); this.handleTrackingChanged_, this);
this.setTracking(options.tracking !== undefined ? options.tracking : false); this.setTracking(options.tracking !== undefined ? options.tracking : false);
@@ -101,22 +101,22 @@ ol.DeviceOrientation.prototype.orientationChange_ = function(originalEvent) {
var event = /** @type {DeviceOrientationEvent} */ (originalEvent); var event = /** @type {DeviceOrientationEvent} */ (originalEvent);
if (event.alpha !== null) { if (event.alpha !== null) {
var alpha = ol.math.toRadians(event.alpha); var alpha = ol.math.toRadians(event.alpha);
this.set(ol.DeviceOrientation.Property.ALPHA, alpha); this.set(ol.DeviceOrientation.Property_.ALPHA, alpha);
// event.absolute is undefined in iOS. // event.absolute is undefined in iOS.
if (typeof event.absolute === 'boolean' && event.absolute) { if (typeof event.absolute === 'boolean' && event.absolute) {
this.set(ol.DeviceOrientation.Property.HEADING, alpha); this.set(ol.DeviceOrientation.Property_.HEADING, alpha);
} else if (typeof event.webkitCompassHeading === 'number' && } else if (typeof event.webkitCompassHeading === 'number' &&
event.webkitCompassAccuracy != -1) { event.webkitCompassAccuracy != -1) {
var heading = ol.math.toRadians(event.webkitCompassHeading); var heading = ol.math.toRadians(event.webkitCompassHeading);
this.set(ol.DeviceOrientation.Property.HEADING, heading); this.set(ol.DeviceOrientation.Property_.HEADING, heading);
} }
} }
if (event.beta !== null) { if (event.beta !== null) {
this.set(ol.DeviceOrientation.Property.BETA, this.set(ol.DeviceOrientation.Property_.BETA,
ol.math.toRadians(event.beta)); ol.math.toRadians(event.beta));
} }
if (event.gamma !== null) { if (event.gamma !== null) {
this.set(ol.DeviceOrientation.Property.GAMMA, this.set(ol.DeviceOrientation.Property_.GAMMA,
ol.math.toRadians(event.gamma)); ol.math.toRadians(event.gamma));
} }
this.changed(); this.changed();
@@ -132,7 +132,7 @@ ol.DeviceOrientation.prototype.orientationChange_ = function(originalEvent) {
*/ */
ol.DeviceOrientation.prototype.getAlpha = function() { ol.DeviceOrientation.prototype.getAlpha = function() {
return /** @type {number|undefined} */ ( return /** @type {number|undefined} */ (
this.get(ol.DeviceOrientation.Property.ALPHA)); this.get(ol.DeviceOrientation.Property_.ALPHA));
}; };
@@ -145,7 +145,7 @@ ol.DeviceOrientation.prototype.getAlpha = function() {
*/ */
ol.DeviceOrientation.prototype.getBeta = function() { ol.DeviceOrientation.prototype.getBeta = function() {
return /** @type {number|undefined} */ ( return /** @type {number|undefined} */ (
this.get(ol.DeviceOrientation.Property.BETA)); this.get(ol.DeviceOrientation.Property_.BETA));
}; };
@@ -158,7 +158,7 @@ ol.DeviceOrientation.prototype.getBeta = function() {
*/ */
ol.DeviceOrientation.prototype.getGamma = function() { ol.DeviceOrientation.prototype.getGamma = function() {
return /** @type {number|undefined} */ ( return /** @type {number|undefined} */ (
this.get(ol.DeviceOrientation.Property.GAMMA)); this.get(ol.DeviceOrientation.Property_.GAMMA));
}; };
@@ -171,7 +171,7 @@ ol.DeviceOrientation.prototype.getGamma = function() {
*/ */
ol.DeviceOrientation.prototype.getHeading = function() { ol.DeviceOrientation.prototype.getHeading = function() {
return /** @type {number|undefined} */ ( return /** @type {number|undefined} */ (
this.get(ol.DeviceOrientation.Property.HEADING)); this.get(ol.DeviceOrientation.Property_.HEADING));
}; };
@@ -183,7 +183,7 @@ ol.DeviceOrientation.prototype.getHeading = function() {
*/ */
ol.DeviceOrientation.prototype.getTracking = function() { ol.DeviceOrientation.prototype.getTracking = function() {
return /** @type {boolean} */ ( return /** @type {boolean} */ (
this.get(ol.DeviceOrientation.Property.TRACKING)); this.get(ol.DeviceOrientation.Property_.TRACKING));
}; };
@@ -212,14 +212,15 @@ ol.DeviceOrientation.prototype.handleTrackingChanged_ = function() {
* @api * @api
*/ */
ol.DeviceOrientation.prototype.setTracking = function(tracking) { ol.DeviceOrientation.prototype.setTracking = function(tracking) {
this.set(ol.DeviceOrientation.Property.TRACKING, tracking); this.set(ol.DeviceOrientation.Property_.TRACKING, tracking);
}; };
/** /**
* @enum {string} * @enum {string}
* @private
*/ */
ol.DeviceOrientation.Property = { ol.DeviceOrientation.Property_ = {
ALPHA: 'alpha', ALPHA: 'alpha',
BETA: 'beta', BETA: 'beta',
GAMMA: 'gamma', GAMMA: 'gamma',