Merge pull request #805 from fredj/cleanup

ol.Geolocation and ol.DeviceOrientation cleanup
This commit is contained in:
Frédéric Junod
2013-06-21 08:07:03 -07:00
2 changed files with 18 additions and 14 deletions
+11 -6
View File
@@ -27,6 +27,10 @@ ol.DeviceOrientationProperty = {
*/ */
ol.DeviceOrientation = function(opt_options) { ol.DeviceOrientation = function(opt_options) {
goog.base(this);
var options = goog.isDef(opt_options) ? opt_options : {};
/** /**
* @private * @private
* @type {?number} * @type {?number}
@@ -37,7 +41,7 @@ ol.DeviceOrientation = function(opt_options) {
ol.Object.getChangeEventType(ol.DeviceOrientationProperty.TRACKING), ol.Object.getChangeEventType(ol.DeviceOrientationProperty.TRACKING),
this.handleTrackingChanged_, false, this); this.handleTrackingChanged_, false, this);
goog.base(this, goog.isDef(opt_options) ? opt_options : {}); this.setTracking(goog.isDef(options.tracking) ? options.tracking : false);
}; };
goog.inherits(ol.DeviceOrientation, ol.Object); goog.inherits(ol.DeviceOrientation, ol.Object);
@@ -90,7 +94,7 @@ ol.DeviceOrientation.prototype.orientationChange_ = function(browserEvent) {
* @return {number|undefined} alpha. * @return {number|undefined} alpha.
*/ */
ol.DeviceOrientation.prototype.getAlpha = function() { ol.DeviceOrientation.prototype.getAlpha = function() {
return /** @type {number} */ ( return /** @type {number|undefined} */ (
this.get(ol.DeviceOrientationProperty.ALPHA)); this.get(ol.DeviceOrientationProperty.ALPHA));
}; };
goog.exportProperty( goog.exportProperty(
@@ -103,7 +107,7 @@ goog.exportProperty(
* @return {number|undefined} beta. * @return {number|undefined} beta.
*/ */
ol.DeviceOrientation.prototype.getBeta = function() { ol.DeviceOrientation.prototype.getBeta = function() {
return /** @type {number} */ ( return /** @type {number|undefined} */ (
this.get(ol.DeviceOrientationProperty.BETA)); this.get(ol.DeviceOrientationProperty.BETA));
}; };
goog.exportProperty( goog.exportProperty(
@@ -116,7 +120,7 @@ goog.exportProperty(
* @return {number|undefined} gamma. * @return {number|undefined} gamma.
*/ */
ol.DeviceOrientation.prototype.getGamma = function() { ol.DeviceOrientation.prototype.getGamma = function() {
return /** @type {number} */ ( return /** @type {number|undefined} */ (
this.get(ol.DeviceOrientationProperty.GAMMA)); this.get(ol.DeviceOrientationProperty.GAMMA));
}; };
goog.exportProperty( goog.exportProperty(
@@ -129,7 +133,7 @@ goog.exportProperty(
* @return {number|undefined} heading. * @return {number|undefined} heading.
*/ */
ol.DeviceOrientation.prototype.getHeading = function() { ol.DeviceOrientation.prototype.getHeading = function() {
return /** @type {number} */ ( return /** @type {number|undefined} */ (
this.get(ol.DeviceOrientationProperty.HEADING)); this.get(ol.DeviceOrientationProperty.HEADING));
}; };
goog.exportProperty( goog.exportProperty(
@@ -139,7 +143,8 @@ goog.exportProperty(
/** /**
* @return {boolean|undefined} tracking. * Are we tracking the device's orientation?
* @return {boolean} tracking.
*/ */
ol.DeviceOrientation.prototype.getTracking = function() { ol.DeviceOrientation.prototype.getTracking = function() {
return /** @type {boolean} */ ( return /** @type {boolean} */ (
+7 -8
View File
@@ -86,9 +86,8 @@ ol.Geolocation = function(opt_options) {
if (goog.isDef(options.trackingOptions)) { if (goog.isDef(options.trackingOptions)) {
this.setTrackingOptions(options.trackingOptions); this.setTrackingOptions(options.trackingOptions);
} }
if (goog.isDef(options.tracking)) {
this.setTracking(options.tracking); this.setTracking(goog.isDef(options.tracking) ? options.tracking : false);
}
}; };
goog.inherits(ol.Geolocation, ol.Object); goog.inherits(ol.Geolocation, ol.Object);
@@ -187,7 +186,7 @@ ol.Geolocation.prototype.positionError_ = function(error) {
* @return {number|undefined} accuracy in meters. * @return {number|undefined} accuracy in meters.
*/ */
ol.Geolocation.prototype.getAccuracy = function() { ol.Geolocation.prototype.getAccuracy = function() {
return /** @type {number} */ ( return /** @type {number|undefined} */ (
this.get(ol.GeolocationProperty.ACCURACY)); this.get(ol.GeolocationProperty.ACCURACY));
}; };
goog.exportProperty( goog.exportProperty(
@@ -243,7 +242,7 @@ goog.exportProperty(
* @return {ol.Coordinate|undefined} position. * @return {ol.Coordinate|undefined} position.
*/ */
ol.Geolocation.prototype.getPosition = function() { ol.Geolocation.prototype.getPosition = function() {
return /** @type {ol.Coordinate} */ ( return /** @type {ol.Coordinate|undefined} */ (
this.get(ol.GeolocationProperty.POSITION)); this.get(ol.GeolocationProperty.POSITION));
}; };
goog.exportProperty( goog.exportProperty(
@@ -257,7 +256,7 @@ goog.exportProperty(
* @return {ol.Projection|undefined} projection. * @return {ol.Projection|undefined} projection.
*/ */
ol.Geolocation.prototype.getProjection = function() { ol.Geolocation.prototype.getProjection = function() {
return /** @type {ol.Projection} */ ( return /** @type {ol.Projection|undefined} */ (
this.get(ol.GeolocationProperty.PROJECTION)); this.get(ol.GeolocationProperty.PROJECTION));
}; };
goog.exportProperty( goog.exportProperty(
@@ -282,7 +281,7 @@ goog.exportProperty(
/** /**
* Are we tracking the user's position? * Are we tracking the user's position?
* @return {boolean|undefined} tracking. * @return {boolean} tracking.
*/ */
ol.Geolocation.prototype.getTracking = function() { ol.Geolocation.prototype.getTracking = function() {
return /** @type {boolean} */ ( return /** @type {boolean} */ (
@@ -299,7 +298,7 @@ goog.exportProperty(
* @return {GeolocationPositionOptions|undefined} Tracking options. * @return {GeolocationPositionOptions|undefined} Tracking options.
*/ */
ol.Geolocation.prototype.getTrackingOptions = function() { ol.Geolocation.prototype.getTrackingOptions = function() {
return /** @type {GeolocationPositionOptions} */ ( return /** @type {GeolocationPositionOptions|undefined} */ (
this.get(ol.GeolocationProperty.TRACKING_OPTIONS)); this.get(ol.GeolocationProperty.TRACKING_OPTIONS));
}; };
goog.exportProperty( goog.exportProperty(