From c4ce85c847755d51db74f1e34f668cb0c47e1437 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Fri, 21 Jun 2013 09:14:41 +0200 Subject: [PATCH 1/2] Add missing 'undefined' in type cast --- src/ol/deviceorientation.js | 8 ++++---- src/ol/geolocation.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ol/deviceorientation.js b/src/ol/deviceorientation.js index cd1126d76d..41bdd1b734 100644 --- a/src/ol/deviceorientation.js +++ b/src/ol/deviceorientation.js @@ -90,7 +90,7 @@ ol.DeviceOrientation.prototype.orientationChange_ = function(browserEvent) { * @return {number|undefined} alpha. */ ol.DeviceOrientation.prototype.getAlpha = function() { - return /** @type {number} */ ( + return /** @type {number|undefined} */ ( this.get(ol.DeviceOrientationProperty.ALPHA)); }; goog.exportProperty( @@ -103,7 +103,7 @@ goog.exportProperty( * @return {number|undefined} beta. */ ol.DeviceOrientation.prototype.getBeta = function() { - return /** @type {number} */ ( + return /** @type {number|undefined} */ ( this.get(ol.DeviceOrientationProperty.BETA)); }; goog.exportProperty( @@ -116,7 +116,7 @@ goog.exportProperty( * @return {number|undefined} gamma. */ ol.DeviceOrientation.prototype.getGamma = function() { - return /** @type {number} */ ( + return /** @type {number|undefined} */ ( this.get(ol.DeviceOrientationProperty.GAMMA)); }; goog.exportProperty( @@ -129,7 +129,7 @@ goog.exportProperty( * @return {number|undefined} heading. */ ol.DeviceOrientation.prototype.getHeading = function() { - return /** @type {number} */ ( + return /** @type {number|undefined} */ ( this.get(ol.DeviceOrientationProperty.HEADING)); }; goog.exportProperty( diff --git a/src/ol/geolocation.js b/src/ol/geolocation.js index abd464d468..f8031a8211 100644 --- a/src/ol/geolocation.js +++ b/src/ol/geolocation.js @@ -187,7 +187,7 @@ ol.Geolocation.prototype.positionError_ = function(error) { * @return {number|undefined} accuracy in meters. */ ol.Geolocation.prototype.getAccuracy = function() { - return /** @type {number} */ ( + return /** @type {number|undefined} */ ( this.get(ol.GeolocationProperty.ACCURACY)); }; goog.exportProperty( @@ -243,7 +243,7 @@ goog.exportProperty( * @return {ol.Coordinate|undefined} position. */ ol.Geolocation.prototype.getPosition = function() { - return /** @type {ol.Coordinate} */ ( + return /** @type {ol.Coordinate|undefined} */ ( this.get(ol.GeolocationProperty.POSITION)); }; goog.exportProperty( @@ -257,7 +257,7 @@ goog.exportProperty( * @return {ol.Projection|undefined} projection. */ ol.Geolocation.prototype.getProjection = function() { - return /** @type {ol.Projection} */ ( + return /** @type {ol.Projection|undefined} */ ( this.get(ol.GeolocationProperty.PROJECTION)); }; goog.exportProperty( @@ -299,7 +299,7 @@ goog.exportProperty( * @return {GeolocationPositionOptions|undefined} Tracking options. */ ol.Geolocation.prototype.getTrackingOptions = function() { - return /** @type {GeolocationPositionOptions} */ ( + return /** @type {GeolocationPositionOptions|undefined} */ ( this.get(ol.GeolocationProperty.TRACKING_OPTIONS)); }; goog.exportProperty( From 9cac8a92dffcf8470ba49040bd3a0263d1d3abb2 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Fri, 21 Jun 2013 09:21:48 +0200 Subject: [PATCH 2/2] Set default 'tracking' property to false --- src/ol/deviceorientation.js | 9 +++++++-- src/ol/geolocation.js | 7 +++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/ol/deviceorientation.js b/src/ol/deviceorientation.js index 41bdd1b734..1b1b25f09a 100644 --- a/src/ol/deviceorientation.js +++ b/src/ol/deviceorientation.js @@ -27,6 +27,10 @@ ol.DeviceOrientationProperty = { */ ol.DeviceOrientation = function(opt_options) { + goog.base(this); + + var options = goog.isDef(opt_options) ? opt_options : {}; + /** * @private * @type {?number} @@ -37,7 +41,7 @@ ol.DeviceOrientation = function(opt_options) { ol.Object.getChangeEventType(ol.DeviceOrientationProperty.TRACKING), 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); @@ -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() { return /** @type {boolean} */ ( diff --git a/src/ol/geolocation.js b/src/ol/geolocation.js index f8031a8211..edb908082e 100644 --- a/src/ol/geolocation.js +++ b/src/ol/geolocation.js @@ -86,9 +86,8 @@ ol.Geolocation = function(opt_options) { if (goog.isDef(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); @@ -282,7 +281,7 @@ goog.exportProperty( /** * Are we tracking the user's position? - * @return {boolean|undefined} tracking. + * @return {boolean} tracking. */ ol.Geolocation.prototype.getTracking = function() { return /** @type {boolean} */ (