diff --git a/src/ol/geom/linestring.js b/src/ol/geom/linestring.js index 7305604068..3aeb2980ff 100644 --- a/src/ol/geom/linestring.js +++ b/src/ol/geom/linestring.js @@ -2,6 +2,7 @@ goog.provide('ol.geom.LineString'); goog.require('goog.array'); goog.require('goog.asserts'); +goog.require('ol'); goog.require('ol.extent'); goog.require('ol.geom.GeometryLayout'); goog.require('ol.geom.GeometryType'); @@ -148,7 +149,8 @@ ol.geom.LineString.prototype.getCoordinateAtM = function(m, opt_extrapolate) { this.layout != ol.geom.GeometryLayout.XYZM) { return null; } - var extrapolate = opt_extrapolate ? opt_extrapolate : false; + var extrapolate = ol.isDef(opt_extrapolate) ? + /** @type {boolean} */ (opt_extrapolate) : false; return ol.geom.flat.lineStringCoordinateAtM(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, m, extrapolate); }; diff --git a/src/ol/interaction/dragrotateandzoominteraction.js b/src/ol/interaction/dragrotateandzoominteraction.js index f764286ce3..c0c8f6df8d 100644 --- a/src/ol/interaction/dragrotateandzoominteraction.js +++ b/src/ol/interaction/dragrotateandzoominteraction.js @@ -1,6 +1,7 @@ goog.provide('ol.interaction.DragRotateAndZoom'); goog.require('goog.math.Vec2'); +goog.require('ol'); goog.require('ol.ViewHint'); goog.require('ol.events.ConditionType'); goog.require('ol.events.condition'); @@ -89,17 +90,17 @@ ol.interaction.DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) { var magnitude = delta.magnitude(); var view = map.getView(); map.render(); - if (this.lastAngle_ !== undefined) { + if (ol.isDef(this.lastAngle_)) { var angleDelta = theta - this.lastAngle_; ol.interaction.Interaction.rotateWithoutConstraints( map, view, view.getRotation() - angleDelta); } this.lastAngle_ = theta; - if (this.lastMagnitude_ !== undefined) { + if (ol.isDef(this.lastMagnitude_)) { var resolution = this.lastMagnitude_ * (view.getResolution() / magnitude); ol.interaction.Interaction.zoomWithoutConstraints(map, view, resolution); } - if (this.lastMagnitude_ !== undefined) { + if (ol.isDef(this.lastMagnitude_)) { this.lastScaleDelta_ = this.lastMagnitude_ / magnitude; } this.lastMagnitude_ = magnitude; diff --git a/src/ol/interaction/dragrotateinteraction.js b/src/ol/interaction/dragrotateinteraction.js index d5815a08c8..c7a97d752b 100644 --- a/src/ol/interaction/dragrotateinteraction.js +++ b/src/ol/interaction/dragrotateinteraction.js @@ -1,5 +1,6 @@ goog.provide('ol.interaction.DragRotate'); +goog.require('ol'); goog.require('ol.ViewHint'); goog.require('ol.events.ConditionType'); goog.require('ol.events.condition'); @@ -68,7 +69,7 @@ ol.interaction.DragRotate.handleDragEvent_ = function(mapBrowserEvent) { var offset = mapBrowserEvent.pixel; var theta = Math.atan2(size[1] / 2 - offset[1], offset[0] - size[0] / 2); - if (this.lastAngle_ !== undefined) { + if (ol.isDef(this.lastAngle_)) { var delta = theta - this.lastAngle_; var view = map.getView(); var rotation = view.getRotation(); diff --git a/src/ol/interaction/interaction.js b/src/ol/interaction/interaction.js index a4e15be650..fc592ec716 100644 --- a/src/ol/interaction/interaction.js +++ b/src/ol/interaction/interaction.js @@ -3,6 +3,7 @@ goog.provide('ol.interaction.Interaction'); goog.provide('ol.interaction.InteractionProperty'); +goog.require('ol'); goog.require('ol.MapBrowserEvent'); goog.require('ol.Object'); goog.require('ol.animation'); @@ -149,7 +150,7 @@ ol.interaction.Interaction.rotateWithoutConstraints = if (goog.isDefAndNotNull(rotation)) { var currentRotation = view.getRotation(); var currentCenter = view.getCenter(); - if (currentRotation !== undefined && currentCenter && + if (ol.isDef(currentRotation) && currentCenter && opt_duration && opt_duration > 0) { map.beforeRender(ol.animation.rotate({ rotation: currentRotation, @@ -220,10 +221,10 @@ ol.interaction.Interaction.zoomWithoutConstraints = if (goog.isDefAndNotNull(resolution)) { var currentResolution = view.getResolution(); var currentCenter = view.getCenter(); - if (currentResolution !== undefined && currentCenter && + if (ol.isDef(currentResolution) && currentCenter && opt_duration && opt_duration > 0) { map.beforeRender(ol.animation.zoom({ - resolution: currentResolution, + resolution: /** @type {number} */ (currentResolution), duration: opt_duration, easing: ol.easing.easeOut })); diff --git a/src/ol/interaction/interactiondefaults.js b/src/ol/interaction/interactiondefaults.js index 081e22927c..2d40d36d26 100644 --- a/src/ol/interaction/interactiondefaults.js +++ b/src/ol/interaction/interactiondefaults.js @@ -1,5 +1,6 @@ goog.provide('ol.interaction'); +goog.require('ol'); goog.require('ol.Collection'); goog.require('ol.Kinetic'); goog.require('ol.interaction.DoubleClickZoom'); @@ -47,13 +48,13 @@ ol.interaction.defaults = function(opt_options) { var kinetic = new ol.Kinetic(-0.005, 0.05, 100); - var altShiftDragRotate = options.altShiftDragRotate !== undefined ? + var altShiftDragRotate = ol.isDef(options.altShiftDragRotate) ? options.altShiftDragRotate : true; if (altShiftDragRotate) { interactions.push(new ol.interaction.DragRotate()); } - var doubleClickZoom = options.doubleClickZoom !== undefined ? + var doubleClickZoom = ol.isDef(options.doubleClickZoom) ? options.doubleClickZoom : true; if (doubleClickZoom) { interactions.push(new ol.interaction.DoubleClickZoom({ @@ -62,27 +63,27 @@ ol.interaction.defaults = function(opt_options) { })); } - var dragPan = options.dragPan !== undefined ? options.dragPan : true; + var dragPan = ol.isDef(options.dragPan) ? options.dragPan : true; if (dragPan) { interactions.push(new ol.interaction.DragPan({ kinetic: kinetic })); } - var pinchRotate = options.pinchRotate !== undefined ? options.pinchRotate : + var pinchRotate = ol.isDef(options.pinchRotate) ? options.pinchRotate : true; if (pinchRotate) { interactions.push(new ol.interaction.PinchRotate()); } - var pinchZoom = options.pinchZoom !== undefined ? options.pinchZoom : true; + var pinchZoom = ol.isDef(options.pinchZoom) ? options.pinchZoom : true; if (pinchZoom) { interactions.push(new ol.interaction.PinchZoom({ duration: options.zoomDuration })); } - var keyboard = options.keyboard !== undefined ? options.keyboard : true; + var keyboard = ol.isDef(options.keyboard) ? options.keyboard : true; if (keyboard) { interactions.push(new ol.interaction.KeyboardPan()); interactions.push(new ol.interaction.KeyboardZoom({ @@ -91,7 +92,7 @@ ol.interaction.defaults = function(opt_options) { })); } - var mouseWheelZoom = options.mouseWheelZoom !== undefined ? + var mouseWheelZoom = ol.isDef(options.mouseWheelZoom) ? options.mouseWheelZoom : true; if (mouseWheelZoom) { interactions.push(new ol.interaction.MouseWheelZoom({ @@ -99,7 +100,7 @@ ol.interaction.defaults = function(opt_options) { })); } - var shiftDragZoom = options.shiftDragZoom !== undefined ? + var shiftDragZoom = ol.isDef(options.shiftDragZoom) ? options.shiftDragZoom : true; if (shiftDragZoom) { interactions.push(new ol.interaction.DragZoom()); diff --git a/src/ol/interaction/modifyinteraction.js b/src/ol/interaction/modifyinteraction.js index cb8989cd07..fa2a5040ff 100644 --- a/src/ol/interaction/modifyinteraction.js +++ b/src/ol/interaction/modifyinteraction.js @@ -7,6 +7,7 @@ goog.require('goog.events'); goog.require('goog.events.Event'); goog.require('goog.events.EventType'); goog.require('goog.functions'); +goog.require('ol'); goog.require('ol.Collection'); goog.require('ol.CollectionEventType'); goog.require('ol.Feature'); @@ -882,13 +883,13 @@ ol.interaction.Modify.prototype.removeVertex_ = function() { segmentsByFeature[uid] = [left, right, index]; } newSegment = segmentsByFeature[uid]; - if (left !== undefined) { + if (ol.isDef(left)) { newSegment[0] = left; } - if (right !== undefined) { + if (ol.isDef(right)) { newSegment[1] = right; } - if (newSegment[0] !== undefined && newSegment[1] !== undefined) { + if (ol.isDef(newSegment[0]) && ol.isDef(newSegment[1])) { component = coordinates; deleted = false; newIndex = index - 1;