Add 'translatestart', 'translateend' and 'translating' events to 'ol.interaction.Translate'

This commit is contained in:
jonataswalker
2015-09-29 08:06:54 -03:00
208 changed files with 1811 additions and 3938 deletions

View File

@@ -18,13 +18,13 @@ goog.require('ol.interaction.Interaction');
*/
ol.interaction.DoubleClickZoom = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {};
var options = opt_options ? opt_options : {};
/**
* @private
* @type {number}
*/
this.delta_ = goog.isDef(options.delta) ? options.delta : 1;
this.delta_ = options.delta ? options.delta : 1;
goog.base(this, {
handleEvent: ol.interaction.DoubleClickZoom.handleEvent
@@ -34,7 +34,7 @@ ol.interaction.DoubleClickZoom = function(opt_options) {
* @private
* @type {number}
*/
this.duration_ = goog.isDef(options.duration) ? options.duration : 250;
this.duration_ = options.duration ? options.duration : 250;
};
goog.inherits(ol.interaction.DoubleClickZoom, ol.interaction.Interaction);

View File

@@ -27,7 +27,7 @@ goog.require('ol.proj');
*/
ol.interaction.DragAndDrop = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {};
var options = opt_options ? opt_options : {};
goog.base(this, {
handleEvent: ol.interaction.DragAndDrop.handleEvent
@@ -37,14 +37,14 @@ ol.interaction.DragAndDrop = function(opt_options) {
* @private
* @type {Array.<function(new: ol.format.Feature)>}
*/
this.formatConstructors_ = goog.isDef(options.formatConstructors) ?
this.formatConstructors_ = options.formatConstructors ?
options.formatConstructors : [];
/**
* @private
* @type {ol.proj.Projection}
*/
this.projection_ = goog.isDef(options.projection) ?
this.projection_ = options.projection ?
ol.proj.get(options.projection) : null;
/**
@@ -67,7 +67,7 @@ goog.inherits(ol.interaction.DragAndDrop, ol.interaction.Interaction);
* @inheritDoc
*/
ol.interaction.DragAndDrop.prototype.disposeInternal = function() {
if (goog.isDef(this.dropListenKey_)) {
if (this.dropListenKey_) {
goog.events.unlistenByKey(this.dropListenKey_);
}
goog.base(this, 'disposeInternal');
@@ -104,7 +104,7 @@ ol.interaction.DragAndDrop.prototype.handleResult_ = function(file, result) {
var view = map.getView();
goog.asserts.assert(!goog.isNull(view), 'view should not be null');
projection = view.getProjection();
goog.asserts.assert(goog.isDef(projection),
goog.asserts.assert(projection !== undefined,
'projection should be defined');
}
var formatConstructors = this.formatConstructors_;
@@ -150,7 +150,7 @@ ol.interaction.DragAndDrop.handleEvent = goog.functions.TRUE;
* @inheritDoc
*/
ol.interaction.DragAndDrop.prototype.setMap = function(map) {
if (goog.isDef(this.dropListenKey_)) {
if (this.dropListenKey_) {
goog.events.unlistenByKey(this.dropListenKey_);
this.dropListenKey_ = undefined;
}
@@ -158,7 +158,7 @@ ol.interaction.DragAndDrop.prototype.setMap = function(map) {
goog.dispose(this.fileDropHandler_);
this.fileDropHandler_ = null;
}
goog.asserts.assert(!goog.isDef(this.dropListenKey_),
goog.asserts.assert(this.dropListenKey_ === undefined,
'this.dropListenKey_ should be undefined');
goog.base(this, 'setMap', map);
if (!goog.isNull(map)) {

View File

@@ -91,13 +91,13 @@ ol.interaction.DragBox = function(opt_options) {
handleUpEvent: ol.interaction.DragBox.handleUpEvent_
});
var options = goog.isDef(opt_options) ? opt_options : {};
var options = opt_options ? opt_options : {};
/**
* @private
* @type {ol.style.Style}
*/
var style = goog.isDef(options.style) ? options.style : null;
var style = options.style ? options.style : null;
/**
* @type {ol.render.Box}
@@ -115,7 +115,7 @@ ol.interaction.DragBox = function(opt_options) {
* @private
* @type {ol.events.ConditionType}
*/
this.condition_ = goog.isDef(options.condition) ?
this.condition_ = options.condition ?
options.condition : ol.events.condition.always;
};

View File

@@ -28,7 +28,7 @@ ol.interaction.DragPan = function(opt_options) {
handleUpEvent: ol.interaction.DragPan.handleUpEvent_
});
var options = goog.isDef(opt_options) ? opt_options : {};
var options = opt_options ? opt_options : {};
/**
* @private
@@ -51,7 +51,7 @@ ol.interaction.DragPan = function(opt_options) {
* @private
* @type {ol.events.ConditionType}
*/
this.condition_ = goog.isDef(options.condition) ?
this.condition_ = options.condition ?
options.condition : ol.events.condition.noModifierKeys;
/**
@@ -109,7 +109,7 @@ ol.interaction.DragPan.handleUpEvent_ = function(mapBrowserEvent) {
var distance = this.kinetic_.getDistance();
var angle = this.kinetic_.getAngle();
var center = view.getCenter();
goog.asserts.assert(goog.isDef(center), 'center should be defined');
goog.asserts.assert(center !== undefined, 'center should be defined');
this.kineticPreRenderFn_ = this.kinetic_.pan(center);
map.beforeRender(this.kineticPreRenderFn_);
var centerpx = map.getPixelFromCoordinate(center);

View File

@@ -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');
@@ -26,7 +27,7 @@ goog.require('ol.interaction.Pointer');
*/
ol.interaction.DragRotateAndZoom = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {};
var options = opt_options ? opt_options : {};
goog.base(this, {
handleDownEvent: ol.interaction.DragRotateAndZoom.handleDownEvent_,
@@ -38,7 +39,7 @@ ol.interaction.DragRotateAndZoom = function(opt_options) {
* @private
* @type {ol.events.ConditionType}
*/
this.condition_ = goog.isDef(options.condition) ?
this.condition_ = options.condition ?
options.condition : ol.events.condition.shiftKeyOnly;
/**
@@ -63,7 +64,7 @@ ol.interaction.DragRotateAndZoom = function(opt_options) {
* @private
* @type {number}
*/
this.duration_ = goog.isDef(options.duration) ? options.duration : 400;
this.duration_ = options.duration ? options.duration : 400;
};
goog.inherits(ol.interaction.DragRotateAndZoom, ol.interaction.Pointer);
@@ -89,17 +90,17 @@ ol.interaction.DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) {
var magnitude = delta.magnitude();
var view = map.getView();
map.render();
if (goog.isDef(this.lastAngle_)) {
if (this.lastAngle_ !== undefined) {
var angleDelta = theta - this.lastAngle_;
ol.interaction.Interaction.rotateWithoutConstraints(
map, view, view.getRotation() - angleDelta);
}
this.lastAngle_ = theta;
if (goog.isDef(this.lastMagnitude_)) {
if (this.lastMagnitude_ !== undefined) {
var resolution = this.lastMagnitude_ * (view.getResolution() / magnitude);
ol.interaction.Interaction.zoomWithoutConstraints(map, view, resolution);
}
if (goog.isDef(this.lastMagnitude_)) {
if (this.lastMagnitude_ !== undefined) {
this.lastScaleDelta_ = this.lastMagnitude_ / magnitude;
}
this.lastMagnitude_ = magnitude;

View File

@@ -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');
@@ -23,7 +24,7 @@ goog.require('ol.interaction.Pointer');
*/
ol.interaction.DragRotate = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {};
var options = opt_options ? opt_options : {};
goog.base(this, {
handleDownEvent: ol.interaction.DragRotate.handleDownEvent_,
@@ -35,7 +36,7 @@ ol.interaction.DragRotate = function(opt_options) {
* @private
* @type {ol.events.ConditionType}
*/
this.condition_ = goog.isDef(options.condition) ?
this.condition_ = options.condition ?
options.condition : ol.events.condition.altShiftKeysOnly;
/**
@@ -48,7 +49,7 @@ ol.interaction.DragRotate = function(opt_options) {
* @private
* @type {number}
*/
this.duration_ = goog.isDef(options.duration) ? options.duration : 250;
this.duration_ = options.duration ? options.duration : 250;
};
goog.inherits(ol.interaction.DragRotate, ol.interaction.Pointer);
@@ -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 (goog.isDef(this.lastAngle_)) {
if (this.lastAngle_ !== undefined) {
var delta = theta - this.lastAngle_;
var view = map.getView();
var rotation = view.getRotation();

View File

@@ -23,22 +23,22 @@ goog.require('ol.style.Style');
* @api stable
*/
ol.interaction.DragZoom = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {};
var options = opt_options ? opt_options : {};
var condition = goog.isDef(options.condition) ?
var condition = options.condition ?
options.condition : ol.events.condition.shiftKeyOnly;
/**
* @private
* @type {number}
*/
this.duration_ = goog.isDef(options.duration) ? options.duration : 200;
this.duration_ = options.duration ? options.duration : 200;
/**
* @private
* @type {ol.style.Style}
*/
var style = goog.isDef(options.style) ?
var style = options.style ?
options.style : new ol.style.Style({
stroke: new ol.style.Stroke({
color: [0, 0, 255, 1]
@@ -64,7 +64,7 @@ ol.interaction.DragZoom.prototype.onBoxEnd = function() {
goog.asserts.assert(!goog.isNull(view), 'view should not be null');
var size = map.getSize();
goog.asserts.assert(goog.isDef(size), 'size should be defined');
goog.asserts.assert(size !== undefined, 'size should be defined');
var extent = this.getGeometry().getExtent();
@@ -72,10 +72,10 @@ ol.interaction.DragZoom.prototype.onBoxEnd = function() {
view.getResolutionForExtent(extent, size));
var currentResolution = view.getResolution();
goog.asserts.assert(goog.isDef(currentResolution), 'res should be defined');
goog.asserts.assert(currentResolution !== undefined, 'res should be defined');
var currentCenter = view.getCenter();
goog.asserts.assert(goog.isDef(currentCenter), 'center should be defined');
goog.asserts.assert(currentCenter !== undefined, 'center should be defined');
map.beforeRender(ol.animation.zoom({
resolution: currentResolution,

View File

@@ -112,22 +112,21 @@ ol.interaction.Draw = function(options) {
* @type {ol.source.Vector}
* @private
*/
this.source_ = goog.isDef(options.source) ? options.source : null;
this.source_ = options.source ? options.source : null;
/**
* Target collection for drawn features.
* @type {ol.Collection.<ol.Feature>}
* @private
*/
this.features_ = goog.isDef(options.features) ? options.features : null;
this.features_ = options.features ? options.features : null;
/**
* Pixel distance for snapping.
* @type {number}
* @private
*/
this.snapTolerance_ = goog.isDef(options.snapTolerance) ?
options.snapTolerance : 12;
this.snapTolerance_ = options.snapTolerance ? options.snapTolerance : 12;
/**
* Geometry type.
@@ -150,7 +149,7 @@ ol.interaction.Draw = function(options) {
* @type {number}
* @private
*/
this.minPoints_ = goog.isDef(options.minPoints) ?
this.minPoints_ = options.minPoints ?
options.minPoints :
(this.mode_ === ol.interaction.DrawMode.POLYGON ? 3 : 2);
@@ -160,11 +159,10 @@ ol.interaction.Draw = function(options) {
* @type {number}
* @private
*/
this.maxPoints_ = goog.isDef(options.maxPoints) ?
options.maxPoints : Infinity;
this.maxPoints_ = options.maxPoints ? options.maxPoints : Infinity;
var geometryFunction = options.geometryFunction;
if (!goog.isDef(geometryFunction)) {
if (!geometryFunction) {
if (this.type_ === ol.geom.GeometryType.CIRCLE) {
/**
* @param {ol.Coordinate|Array.<ol.Coordinate>|Array.<Array.<ol.Coordinate>>} coordinates
@@ -172,7 +170,7 @@ ol.interaction.Draw = function(options) {
* @return {ol.geom.SimpleGeometry}
*/
geometryFunction = function(coordinates, opt_geometry) {
var circle = goog.isDef(opt_geometry) ? opt_geometry :
var circle = opt_geometry ? opt_geometry :
new ol.geom.Circle([NaN, NaN]);
goog.asserts.assertInstanceof(circle, ol.geom.Circle,
'geometry must be an ol.geom.Circle');
@@ -198,7 +196,7 @@ ol.interaction.Draw = function(options) {
*/
geometryFunction = function(coordinates, opt_geometry) {
var geometry = opt_geometry;
if (goog.isDef(geometry)) {
if (geometry) {
geometry.setCoordinates(coordinates);
} else {
geometry = new Constructor(coordinates);
@@ -264,7 +262,7 @@ ol.interaction.Draw = function(options) {
* @type {number}
* @private
*/
this.squaredClickTolerance_ = goog.isDef(options.clickTolerance) ?
this.squaredClickTolerance_ = options.clickTolerance ?
options.clickTolerance * options.clickTolerance : 36;
/**
@@ -275,10 +273,10 @@ ol.interaction.Draw = function(options) {
this.overlay_ = new ol.layer.Vector({
source: new ol.source.Vector({
useSpatialIndex: false,
wrapX: goog.isDef(options.wrapX) ? options.wrapX : false
wrapX: options.wrapX ? options.wrapX : false
}),
style: goog.isDef(options.style) ?
options.style : ol.interaction.Draw.getDefaultStyleFunction()
style: options.style ? options.style :
ol.interaction.Draw.getDefaultStyleFunction()
});
/**
@@ -292,14 +290,14 @@ ol.interaction.Draw = function(options) {
* @private
* @type {ol.events.ConditionType}
*/
this.condition_ = goog.isDef(options.condition) ?
this.condition_ = options.condition ?
options.condition : ol.events.condition.noModifierKeys;
/**
* @private
* @type {ol.events.ConditionType}
*/
this.freehandCondition_ = goog.isDef(options.freehandCondition) ?
this.freehandCondition_ = options.freehandCondition ?
options.freehandCondition : ol.events.condition.shiftKeyOnly;
goog.events.listen(this,
@@ -512,9 +510,9 @@ ol.interaction.Draw.prototype.startDrawing_ = function(event) {
new ol.geom.LineString(this.sketchLineCoords_));
}
var geometry = this.geometryFunction_(this.sketchCoords_);
goog.asserts.assert(goog.isDef(geometry), 'geometry should be defined');
goog.asserts.assert(geometry !== undefined, 'geometry should be defined');
this.sketchFeature_ = new ol.Feature();
if (goog.isDef(this.geometryName_)) {
if (this.geometryName_) {
this.sketchFeature_.setGeometryName(this.geometryName_);
}
this.sketchFeature_.setGeometry(geometry);
@@ -806,11 +804,11 @@ ol.interaction.Draw.createRegularPolygon = function(opt_sides, opt_angle) {
var end = coordinates[1];
var radius = Math.sqrt(
ol.coordinate.squaredDistance(center, end));
var geometry = goog.isDef(opt_geometry) ? opt_geometry :
var geometry = opt_geometry ? opt_geometry :
ol.geom.Polygon.fromCircle(new ol.geom.Circle(center), opt_sides);
goog.asserts.assertInstanceof(geometry, ol.geom.Polygon,
'geometry must be a polygon');
var angle = goog.isDef(opt_angle) ? opt_angle :
var angle = opt_angle ? opt_angle :
Math.atan((end[1] - center[1]) / (end[0] - center[0]));
ol.geom.Polygon.makeRegular(geometry, center, radius, angle);
return geometry;
@@ -840,7 +838,7 @@ ol.interaction.Draw.getMode_ = function(type) {
} else if (type === ol.geom.GeometryType.CIRCLE) {
mode = ol.interaction.DrawMode.CIRCLE;
}
goog.asserts.assert(goog.isDef(mode), 'mode should be defined');
goog.asserts.assert(mode !== undefined, 'mode should be defined');
return mode;
};

View File

@@ -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');
@@ -107,8 +108,8 @@ ol.interaction.Interaction.prototype.setMap = function(map) {
*/
ol.interaction.Interaction.pan = function(map, view, delta, opt_duration) {
var currentCenter = view.getCenter();
if (goog.isDef(currentCenter)) {
if (goog.isDef(opt_duration) && opt_duration > 0) {
if (currentCenter) {
if (opt_duration && opt_duration > 0) {
map.beforeRender(ol.animation.pan({
source: currentCenter,
duration: opt_duration,
@@ -149,14 +150,14 @@ ol.interaction.Interaction.rotateWithoutConstraints =
if (goog.isDefAndNotNull(rotation)) {
var currentRotation = view.getRotation();
var currentCenter = view.getCenter();
if (goog.isDef(currentRotation) && goog.isDef(currentCenter) &&
goog.isDef(opt_duration) && opt_duration > 0) {
if (currentRotation !== undefined && currentCenter &&
opt_duration && opt_duration > 0) {
map.beforeRender(ol.animation.rotate({
rotation: currentRotation,
duration: opt_duration,
easing: ol.easing.easeOut
}));
if (goog.isDef(opt_anchor)) {
if (opt_anchor) {
map.beforeRender(ol.animation.pan({
source: currentCenter,
duration: opt_duration,
@@ -220,14 +221,15 @@ ol.interaction.Interaction.zoomWithoutConstraints =
if (goog.isDefAndNotNull(resolution)) {
var currentResolution = view.getResolution();
var currentCenter = view.getCenter();
if (goog.isDef(currentResolution) && goog.isDef(currentCenter) &&
goog.isDef(opt_duration) && opt_duration > 0) {
if (currentResolution !== undefined && currentCenter &&
resolution !== currentResolution &&
opt_duration && opt_duration > 0) {
map.beforeRender(ol.animation.zoom({
resolution: currentResolution,
resolution: /** @type {number} */ (currentResolution),
duration: opt_duration,
easing: ol.easing.easeOut
}));
if (goog.isDef(opt_anchor)) {
if (opt_anchor) {
map.beforeRender(ol.animation.pan({
source: currentCenter,
duration: opt_duration,

View File

@@ -1,5 +1,6 @@
goog.provide('ol.interaction');
goog.require('ol');
goog.require('ol.Collection');
goog.require('ol.Kinetic');
goog.require('ol.interaction.DoubleClickZoom');
@@ -41,19 +42,19 @@ goog.require('ol.interaction.PinchZoom');
*/
ol.interaction.defaults = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {};
var options = opt_options ? opt_options : {};
var interactions = new ol.Collection();
var kinetic = new ol.Kinetic(-0.005, 0.05, 100);
var altShiftDragRotate = goog.isDef(options.altShiftDragRotate) ?
var altShiftDragRotate = options.altShiftDragRotate !== undefined ?
options.altShiftDragRotate : true;
if (altShiftDragRotate) {
interactions.push(new ol.interaction.DragRotate());
}
var doubleClickZoom = goog.isDef(options.doubleClickZoom) ?
var doubleClickZoom = options.doubleClickZoom !== undefined ?
options.doubleClickZoom : true;
if (doubleClickZoom) {
interactions.push(new ol.interaction.DoubleClickZoom({
@@ -62,30 +63,27 @@ ol.interaction.defaults = function(opt_options) {
}));
}
var dragPan = goog.isDef(options.dragPan) ?
options.dragPan : true;
var dragPan = options.dragPan !== undefined ? options.dragPan : true;
if (dragPan) {
interactions.push(new ol.interaction.DragPan({
kinetic: kinetic
}));
}
var pinchRotate = goog.isDef(options.pinchRotate) ?
options.pinchRotate : true;
var pinchRotate = options.pinchRotate !== undefined ? options.pinchRotate :
true;
if (pinchRotate) {
interactions.push(new ol.interaction.PinchRotate());
}
var pinchZoom = goog.isDef(options.pinchZoom) ?
options.pinchZoom : true;
var pinchZoom = options.pinchZoom !== undefined ? options.pinchZoom : true;
if (pinchZoom) {
interactions.push(new ol.interaction.PinchZoom({
duration: options.zoomDuration
}));
}
var keyboard = goog.isDef(options.keyboard) ?
options.keyboard : true;
var keyboard = options.keyboard !== undefined ? options.keyboard : true;
if (keyboard) {
interactions.push(new ol.interaction.KeyboardPan());
interactions.push(new ol.interaction.KeyboardZoom({
@@ -94,7 +92,7 @@ ol.interaction.defaults = function(opt_options) {
}));
}
var mouseWheelZoom = goog.isDef(options.mouseWheelZoom) ?
var mouseWheelZoom = options.mouseWheelZoom !== undefined ?
options.mouseWheelZoom : true;
if (mouseWheelZoom) {
interactions.push(new ol.interaction.MouseWheelZoom({
@@ -102,7 +100,7 @@ ol.interaction.defaults = function(opt_options) {
}));
}
var shiftDragZoom = goog.isDef(options.shiftDragZoom) ?
var shiftDragZoom = options.shiftDragZoom !== undefined ?
options.shiftDragZoom : true;
if (shiftDragZoom) {
interactions.push(new ol.interaction.DragZoom());

View File

@@ -4,6 +4,7 @@ goog.require('goog.asserts');
goog.require('goog.events.KeyCodes');
goog.require('goog.events.KeyHandler.EventType');
goog.require('goog.functions');
goog.require('ol');
goog.require('ol.coordinate');
goog.require('ol.events.ConditionType');
goog.require('ol.events.condition');
@@ -34,13 +35,14 @@ ol.interaction.KeyboardPan = function(opt_options) {
handleEvent: ol.interaction.KeyboardPan.handleEvent
});
var options = goog.isDef(opt_options) ? opt_options : {};
var options = opt_options || {};
/**
* @private
* @type {ol.events.ConditionType}
*/
this.condition_ = goog.isDef(options.condition) ? options.condition :
this.condition_ = options.condition !== undefined ?
options.condition :
goog.functions.and(ol.events.condition.noModifierKeys,
ol.events.condition.targetNotEditable);
@@ -48,13 +50,14 @@ ol.interaction.KeyboardPan = function(opt_options) {
* @private
* @type {number}
*/
this.duration_ = goog.isDef(options.duration) ? options.duration : 100;
this.duration_ = options.duration !== undefined ? options.duration : 100;
/**
* @private
* @type {number}
*/
this.pixelDelta_ = goog.isDef(options.pixelDelta) ? options.pixelDelta : 128;
this.pixelDelta_ = options.pixelDelta !== undefined ?
options.pixelDelta : 128;
};
goog.inherits(ol.interaction.KeyboardPan, ol.interaction.Interaction);

View File

@@ -31,26 +31,26 @@ ol.interaction.KeyboardZoom = function(opt_options) {
handleEvent: ol.interaction.KeyboardZoom.handleEvent
});
var options = goog.isDef(opt_options) ? opt_options : {};
var options = opt_options ? opt_options : {};
/**
* @private
* @type {ol.events.ConditionType}
*/
this.condition_ = goog.isDef(options.condition) ? options.condition :
this.condition_ = options.condition ? options.condition :
ol.events.condition.targetNotEditable;
/**
* @private
* @type {number}
*/
this.delta_ = goog.isDef(options.delta) ? options.delta : 1;
this.delta_ = options.delta ? options.delta : 1;
/**
* @private
* @type {number}
*/
this.duration_ = goog.isDef(options.duration) ? options.duration : 100;
this.duration_ = options.duration ? options.duration : 100;
};
goog.inherits(ol.interaction.KeyboardZoom, ol.interaction.Interaction);

View File

@@ -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');
@@ -116,7 +117,7 @@ ol.interaction.Modify = function(options) {
* @type {ol.events.ConditionType}
* @private
*/
this.deleteCondition_ = goog.isDef(options.deleteCondition) ?
this.deleteCondition_ = options.deleteCondition ?
options.deleteCondition :
/** @type {ol.events.ConditionType} */ (goog.functions.and(
ol.events.condition.noModifierKeys,
@@ -161,7 +162,7 @@ ol.interaction.Modify = function(options) {
* @type {number}
* @private
*/
this.pixelTolerance_ = goog.isDef(options.pixelTolerance) ?
this.pixelTolerance_ = options.pixelTolerance !== undefined ?
options.pixelTolerance : 10;
/**
@@ -192,9 +193,9 @@ ol.interaction.Modify = function(options) {
this.overlay_ = new ol.layer.Vector({
source: new ol.source.Vector({
useSpatialIndex: false,
wrapX: goog.isDef(options.wrapX) ? options.wrapX : false
wrapX: !!options.wrapX
}),
style: goog.isDef(options.style) ? options.style :
style: options.style ? options.style :
ol.interaction.Modify.getDefaultStyleFunction(),
updateWhileAnimating: true,
updateWhileInteracting: true
@@ -238,7 +239,7 @@ goog.inherits(ol.interaction.Modify, ol.interaction.Pointer);
*/
ol.interaction.Modify.prototype.addFeature_ = function(feature) {
var geometry = feature.getGeometry();
if (goog.isDef(this.SEGMENT_WRITERS_[geometry.getType()])) {
if (geometry.getType() in this.SEGMENT_WRITERS_) {
this.SEGMENT_WRITERS_[geometry.getType()].call(this, feature, geometry);
}
var map = this.getMap();
@@ -822,10 +823,10 @@ ol.interaction.Modify.prototype.insertVertex_ = function(segmentData, vertex) {
this.setGeometryCoordinates_(geometry, coordinates);
var rTree = this.rBush_;
goog.asserts.assert(goog.isDef(segment), 'segment should be defined');
goog.asserts.assert(segment !== undefined, 'segment should be defined');
rTree.remove(segmentData);
goog.asserts.assert(goog.isDef(index), 'index should be defined');
this.updateSegmentIndices_(geometry, index, depth, 1);
goog.asserts.assert(index !== undefined, 'index should be defined');
this.updateSegmentIndices_(geometry, /** @type {number} */ (index), depth, 1);
var newSegmentData = /** @type {ol.interaction.SegmentDataType} */ ({
segment: [segment[0], vertex],
feature: feature,
@@ -883,13 +884,13 @@ ol.interaction.Modify.prototype.removeVertex_ = function() {
segmentsByFeature[uid] = [left, right, index];
}
newSegment = segmentsByFeature[uid];
if (goog.isDef(left)) {
if (left !== undefined) {
newSegment[0] = left;
}
if (goog.isDef(right)) {
if (right !== undefined) {
newSegment[1] = right;
}
if (goog.isDef(newSegment[0]) && goog.isDef(newSegment[1])) {
if (newSegment[0] !== undefined && newSegment[1] !== undefined) {
component = coordinates;
deleted = false;
newIndex = index - 1;
@@ -973,10 +974,11 @@ ol.interaction.Modify.prototype.setGeometryCoordinates_ =
ol.interaction.Modify.prototype.updateSegmentIndices_ = function(
geometry, index, depth, delta) {
this.rBush_.forEachInExtent(geometry.getExtent(), function(segmentDataMatch) {
goog.asserts.assert(goog.isDef(segmentDataMatch.depth));
if (segmentDataMatch.geometry === geometry &&
(!goog.isDef(depth) ||
goog.array.equals(segmentDataMatch.depth, depth)) &&
(depth === undefined || segmentDataMatch.depth === undefined ||
goog.array.equals(
/** @type {null|{length: number}} */ (segmentDataMatch.depth),
depth)) &&
segmentDataMatch.index > index) {
segmentDataMatch.index += delta;
}

View File

@@ -3,10 +3,10 @@ goog.provide('ol.interaction.MouseWheelZoom');
goog.require('goog.asserts');
goog.require('goog.events.MouseWheelEvent');
goog.require('goog.events.MouseWheelHandler.EventType');
goog.require('goog.math');
goog.require('ol');
goog.require('ol.Coordinate');
goog.require('ol.interaction.Interaction');
goog.require('ol.math');
@@ -25,7 +25,7 @@ ol.interaction.MouseWheelZoom = function(opt_options) {
handleEvent: ol.interaction.MouseWheelZoom.handleEvent
});
var options = goog.isDef(opt_options) ? opt_options : {};
var options = opt_options || {};
/**
* @private
@@ -37,14 +37,13 @@ ol.interaction.MouseWheelZoom = function(opt_options) {
* @private
* @type {number}
*/
this.duration_ = goog.isDef(options.duration) ? options.duration : 250;
this.duration_ = options.duration !== undefined ? options.duration : 250;
/**
* @private
* @type {boolean}
*/
this.useAnchor_ = goog.isDef(options.useAnchor) ?
options.useAnchor : true;
this.useAnchor_ = options.useAnchor !== undefined ? options.useAnchor : true;
/**
* @private
@@ -91,12 +90,12 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
this.delta_ += mouseWheelEvent.deltaY;
if (!goog.isDef(this.startTime_)) {
this.startTime_ = goog.now();
if (this.startTime_ === undefined) {
this.startTime_ = Date.now();
}
var duration = ol.MOUSEWHEELZOOM_TIMEOUT_DURATION;
var timeLeft = Math.max(duration - (goog.now() - this.startTime_), 0);
var timeLeft = Math.max(duration - (Date.now() - this.startTime_), 0);
goog.global.clearTimeout(this.timeoutId_);
this.timeoutId_ = goog.global.setTimeout(
@@ -115,7 +114,7 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
*/
ol.interaction.MouseWheelZoom.prototype.doZoom_ = function(map) {
var maxDelta = ol.MOUSEWHEELZOOM_MAXDELTA;
var delta = goog.math.clamp(this.delta_, -maxDelta, maxDelta);
var delta = ol.math.clamp(this.delta_, -maxDelta, maxDelta);
var view = map.getView();
goog.asserts.assert(!goog.isNull(view), 'view should not be null');

View File

@@ -3,6 +3,7 @@ goog.provide('ol.interaction.PinchRotate');
goog.require('goog.asserts');
goog.require('goog.functions');
goog.require('goog.style');
goog.require('ol');
goog.require('ol.Coordinate');
goog.require('ol.ViewHint');
goog.require('ol.interaction.Interaction');
@@ -28,7 +29,7 @@ ol.interaction.PinchRotate = function(opt_options) {
handleUpEvent: ol.interaction.PinchRotate.handleUpEvent_
});
var options = goog.isDef(opt_options) ? opt_options : {};
var options = opt_options || {};
/**
* @private
@@ -58,13 +59,13 @@ ol.interaction.PinchRotate = function(opt_options) {
* @private
* @type {number}
*/
this.threshold_ = goog.isDef(options.threshold) ? options.threshold : 0.3;
this.threshold_ = options.threshold !== undefined ? options.threshold : 0.3;
/**
* @private
* @type {number}
*/
this.duration_ = goog.isDef(options.duration) ? options.duration : 250;
this.duration_ = options.duration !== undefined ? options.duration : 250;
};
goog.inherits(ol.interaction.PinchRotate, ol.interaction.Pointer);
@@ -88,7 +89,7 @@ ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) {
touch1.clientY - touch0.clientY,
touch1.clientX - touch0.clientX);
if (goog.isDef(this.lastAngle_)) {
if (this.lastAngle_ !== undefined) {
var delta = angle - this.lastAngle_;
this.rotationDelta_ += delta;
if (!this.rotating_ &&

View File

@@ -3,6 +3,7 @@ goog.provide('ol.interaction.PinchZoom');
goog.require('goog.asserts');
goog.require('goog.functions');
goog.require('goog.style');
goog.require('ol');
goog.require('ol.Coordinate');
goog.require('ol.ViewHint');
goog.require('ol.interaction.Interaction');
@@ -28,7 +29,7 @@ ol.interaction.PinchZoom = function(opt_options) {
handleUpEvent: ol.interaction.PinchZoom.handleUpEvent_
});
var options = goog.isDef(opt_options) ? opt_options : {};
var options = opt_options ? opt_options : {};
/**
* @private
@@ -40,7 +41,7 @@ ol.interaction.PinchZoom = function(opt_options) {
* @private
* @type {number}
*/
this.duration_ = goog.isDef(options.duration) ? options.duration : 400;
this.duration_ = options.duration !== undefined ? options.duration : 400;
/**
* @private
@@ -76,7 +77,7 @@ ol.interaction.PinchZoom.handleDragEvent_ = function(mapBrowserEvent) {
// distance between touches
var distance = Math.sqrt(dx * dx + dy * dy);
if (goog.isDef(this.lastDistance_)) {
if (this.lastDistance_ !== undefined) {
scaleDelta = this.lastDistance_ / distance;
}
this.lastDistance_ = distance;

View File

@@ -26,9 +26,9 @@ goog.require('ol.interaction.Interaction');
*/
ol.interaction.Pointer = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {};
var options = opt_options ? opt_options : {};
var handleEvent = goog.isDef(options.handleEvent) ?
var handleEvent = options.handleEvent ?
options.handleEvent : ol.interaction.Pointer.handleEvent;
goog.base(this, {
@@ -39,28 +39,28 @@ ol.interaction.Pointer = function(opt_options) {
* @type {function(ol.MapBrowserPointerEvent):boolean}
* @private
*/
this.handleDownEvent_ = goog.isDef(options.handleDownEvent) ?
this.handleDownEvent_ = options.handleDownEvent ?
options.handleDownEvent : ol.interaction.Pointer.handleDownEvent;
/**
* @type {function(ol.MapBrowserPointerEvent)}
* @private
*/
this.handleDragEvent_ = goog.isDef(options.handleDragEvent) ?
this.handleDragEvent_ = options.handleDragEvent ?
options.handleDragEvent : ol.interaction.Pointer.handleDragEvent;
/**
* @type {function(ol.MapBrowserPointerEvent)}
* @private
*/
this.handleMoveEvent_ = goog.isDef(options.handleMoveEvent) ?
this.handleMoveEvent_ = options.handleMoveEvent ?
options.handleMoveEvent : ol.interaction.Pointer.handleMoveEvent;
/**
* @type {function(ol.MapBrowserPointerEvent):boolean}
* @private
*/
this.handleUpEvent_ = goog.isDef(options.handleUpEvent) ?
this.handleUpEvent_ = options.handleUpEvent ?
options.handleUpEvent : ol.interaction.Pointer.handleUpEvent;
/**

View File

@@ -10,6 +10,7 @@ goog.require('goog.events.Event');
goog.require('goog.functions');
goog.require('ol.CollectionEventType');
goog.require('ol.Feature');
goog.require('ol.array');
goog.require('ol.events.condition');
goog.require('ol.geom.GeometryType');
goog.require('ol.interaction.Interaction');
@@ -105,51 +106,51 @@ ol.interaction.Select = function(opt_options) {
handleEvent: ol.interaction.Select.handleEvent
});
var options = goog.isDef(opt_options) ? opt_options : {};
var options = opt_options ? opt_options : {};
/**
* @private
* @type {ol.events.ConditionType}
*/
this.condition_ = goog.isDef(options.condition) ?
this.condition_ = options.condition ?
options.condition : ol.events.condition.singleClick;
/**
* @private
* @type {ol.events.ConditionType}
*/
this.addCondition_ = goog.isDef(options.addCondition) ?
this.addCondition_ = options.addCondition ?
options.addCondition : ol.events.condition.never;
/**
* @private
* @type {ol.events.ConditionType}
*/
this.removeCondition_ = goog.isDef(options.removeCondition) ?
this.removeCondition_ = options.removeCondition ?
options.removeCondition : ol.events.condition.never;
/**
* @private
* @type {ol.events.ConditionType}
*/
this.toggleCondition_ = goog.isDef(options.toggleCondition) ?
this.toggleCondition_ = options.toggleCondition ?
options.toggleCondition : ol.events.condition.shiftKeyOnly;
/**
* @private
* @type {boolean}
*/
this.multi_ = goog.isDef(options.multi) ? options.multi : false;
this.multi_ = options.multi ? options.multi : false;
/**
* @private
* @type {ol.interaction.SelectFilterFunction}
*/
this.filter_ = goog.isDef(options.filter) ? options.filter :
this.filter_ = options.filter ? options.filter :
goog.functions.TRUE;
var layerFilter;
if (goog.isDef(options.layers)) {
if (options.layers) {
if (goog.isFunction(options.layers)) {
layerFilter = options.layers;
} else {
@@ -160,7 +161,7 @@ ol.interaction.Select = function(opt_options) {
* @return {boolean} Include.
*/
function(layer) {
return goog.array.contains(layers, layer);
return ol.array.includes(layers, layer);
};
}
} else {
@@ -180,9 +181,10 @@ ol.interaction.Select = function(opt_options) {
this.featureOverlay_ = new ol.layer.Vector({
source: new ol.source.Vector({
useSpatialIndex: false,
features: options.features,
wrapX: options.wrapX
}),
style: goog.isDef(options.style) ? options.style :
style: options.style ? options.style :
ol.interaction.Select.getDefaultStyleFunction(),
updateWhileAnimating: true,
updateWhileInteracting: true
@@ -263,8 +265,7 @@ ol.interaction.Select.handleEvent = function(mapBrowserEvent) {
* @param {ol.layer.Layer} layer Layer.
*/
function(feature, layer) {
var index = goog.array.indexOf(features.getArray(), feature);
if (index == -1) {
if (!ol.array.includes(features.getArray(), feature)) {
if (add || toggle) {
if (this.filter_(feature, layer)) {
selected.push(feature);

View File

@@ -6,6 +6,7 @@ goog.require('goog.asserts');
goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('goog.object');
goog.require('ol');
goog.require('ol.Collection');
goog.require('ol.CollectionEvent');
goog.require('ol.CollectionEventType');
@@ -54,19 +55,19 @@ ol.interaction.Snap = function(opt_options) {
handleUpEvent: ol.interaction.Snap.handleUpEvent_
});
var options = goog.isDef(opt_options) ? opt_options : {};
var options = opt_options ? opt_options : {};
/**
* @type {ol.source.Vector}
* @private
*/
this.source_ = goog.isDef(options.source) ? options.source : null;
this.source_ = options.source ? options.source : null;
/**
* @type {ol.Collection.<ol.Feature>}
* @private
*/
this.features_ = goog.isDef(options.features) ? options.features : null;
this.features_ = options.features ? options.features : null;
/**
* @type {Array.<goog.events.Key>}
@@ -114,7 +115,7 @@ ol.interaction.Snap = function(opt_options) {
* @type {number}
* @private
*/
this.pixelTolerance_ = goog.isDef(options.pixelTolerance) ?
this.pixelTolerance_ = options.pixelTolerance !== undefined ?
options.pixelTolerance : 10;
/**
@@ -159,10 +160,10 @@ goog.inherits(ol.interaction.Snap, ol.interaction.Pointer);
* @api
*/
ol.interaction.Snap.prototype.addFeature = function(feature, opt_listen) {
var listen = goog.isDef(opt_listen) ? opt_listen : true;
var listen = opt_listen !== undefined ? opt_listen : true;
var geometry = feature.getGeometry();
var segmentWriter = this.SEGMENT_WRITERS_[geometry.getType()];
if (goog.isDef(segmentWriter)) {
if (segmentWriter) {
var feature_uid = goog.getUid(feature);
this.indexedFeaturesExtents_[feature_uid] = geometry.getExtent(
ol.extent.createEmpty());
@@ -210,7 +211,7 @@ ol.interaction.Snap.prototype.getFeatures_ = function() {
} else if (!goog.isNull(this.source_)) {
features = this.source_.getFeatures();
}
goog.asserts.assert(goog.isDef(features), 'features should be defined');
goog.asserts.assert(features !== undefined, 'features should be defined');
return features;
};
@@ -286,7 +287,7 @@ ol.interaction.Snap.prototype.handleGeometryModify_ = function(feature, evt) {
* @api
*/
ol.interaction.Snap.prototype.removeFeature = function(feature, opt_unlisten) {
var unlisten = goog.isDef(opt_unlisten) ? opt_unlisten : true;
var unlisten = opt_unlisten !== undefined ? opt_unlisten : true;
var feature_uid = goog.getUid(feature);
var extent = this.indexedFeaturesExtents_[feature_uid];
if (extent) {

View File

@@ -1,9 +1,9 @@
goog.provide('ol.interaction.Translate');
goog.provide('ol.interaction.TranslateEvent');
goog.require('goog.array');
goog.require('goog.events');
goog.require('goog.events.Event');
goog.require('ol.array');
goog.require('ol.interaction.Pointer');
@@ -106,7 +106,7 @@ ol.interaction.Translate = function(options) {
* @type {ol.Collection.<ol.Feature>}
* @private
*/
this.features_ = goog.isDef(options.features) ? options.features : null;
this.features_ = options.features !== undefined ? options.features : null;
/**
* @type {ol.Feature}
@@ -207,7 +207,7 @@ ol.interaction.Translate.handleMoveEvent_ = function(event)
var isSelected = false;
if (!goog.isNull(this.features_) &&
goog.array.contains(this.features_.getArray(), intersectingFeature)) {
ol.array.includes(this.features_.getArray(), intersectingFeature)) {
isSelected = true;
}
@@ -223,7 +223,7 @@ ol.interaction.Translate.handleMoveEvent_ = function(event)
'grabbing' : (isSelected ? 'grab' : 'pointer');
} else {
elem.style.cursor = goog.isDef(this.previousCursor_) ?
elem.style.cursor = this.previousCursor_ !== undefined ?
this.previousCursor_ : '';
this.previousCursor_ = undefined;
}
@@ -248,7 +248,7 @@ ol.interaction.Translate.prototype.featuresAtPixel_ = function(pixel, map) {
});
if (!goog.isNull(this.features_) &&
goog.array.contains(this.features_.getArray(), intersectingFeature)) {
ol.array.includes(this.features_.getArray(), intersectingFeature)) {
found = intersectingFeature;
}