Toward natural JavaScript syntax
This commit is contained in:
@@ -90,17 +90,17 @@ ol.interaction.DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
var magnitude = delta.magnitude();
|
||||
var view = map.getView();
|
||||
map.render();
|
||||
if (ol.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 (ol.isDef(this.lastMagnitude_)) {
|
||||
if (this.lastMagnitude_ !== undefined) {
|
||||
var resolution = this.lastMagnitude_ * (view.getResolution() / magnitude);
|
||||
ol.interaction.Interaction.zoomWithoutConstraints(map, view, resolution);
|
||||
}
|
||||
if (ol.isDef(this.lastMagnitude_)) {
|
||||
if (this.lastMagnitude_ !== undefined) {
|
||||
this.lastScaleDelta_ = this.lastMagnitude_ / magnitude;
|
||||
}
|
||||
this.lastMagnitude_ = magnitude;
|
||||
|
||||
@@ -69,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 (ol.isDef(this.lastAngle_)) {
|
||||
if (this.lastAngle_ !== undefined) {
|
||||
var delta = theta - this.lastAngle_;
|
||||
var view = map.getView();
|
||||
var rotation = view.getRotation();
|
||||
|
||||
@@ -150,7 +150,7 @@ ol.interaction.Interaction.rotateWithoutConstraints =
|
||||
if (goog.isDefAndNotNull(rotation)) {
|
||||
var currentRotation = view.getRotation();
|
||||
var currentCenter = view.getCenter();
|
||||
if (ol.isDef(currentRotation) && currentCenter &&
|
||||
if (currentRotation !== undefined && currentCenter &&
|
||||
opt_duration && opt_duration > 0) {
|
||||
map.beforeRender(ol.animation.rotate({
|
||||
rotation: currentRotation,
|
||||
@@ -221,7 +221,7 @@ ol.interaction.Interaction.zoomWithoutConstraints =
|
||||
if (goog.isDefAndNotNull(resolution)) {
|
||||
var currentResolution = view.getResolution();
|
||||
var currentCenter = view.getCenter();
|
||||
if (ol.isDef(currentResolution) && currentCenter &&
|
||||
if (currentResolution !== undefined && currentCenter &&
|
||||
opt_duration && opt_duration > 0) {
|
||||
map.beforeRender(ol.animation.zoom({
|
||||
resolution: /** @type {number} */ (currentResolution),
|
||||
|
||||
@@ -48,13 +48,13 @@ ol.interaction.defaults = function(opt_options) {
|
||||
|
||||
var kinetic = new ol.Kinetic(-0.005, 0.05, 100);
|
||||
|
||||
var altShiftDragRotate = ol.isDef(options.altShiftDragRotate) ?
|
||||
var altShiftDragRotate = options.altShiftDragRotate !== undefined ?
|
||||
options.altShiftDragRotate : true;
|
||||
if (altShiftDragRotate) {
|
||||
interactions.push(new ol.interaction.DragRotate());
|
||||
}
|
||||
|
||||
var doubleClickZoom = ol.isDef(options.doubleClickZoom) ?
|
||||
var doubleClickZoom = options.doubleClickZoom !== undefined ?
|
||||
options.doubleClickZoom : true;
|
||||
if (doubleClickZoom) {
|
||||
interactions.push(new ol.interaction.DoubleClickZoom({
|
||||
@@ -63,27 +63,27 @@ ol.interaction.defaults = function(opt_options) {
|
||||
}));
|
||||
}
|
||||
|
||||
var dragPan = ol.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 = ol.isDef(options.pinchRotate) ? options.pinchRotate :
|
||||
var pinchRotate = options.pinchRotate !== undefined ? options.pinchRotate :
|
||||
true;
|
||||
if (pinchRotate) {
|
||||
interactions.push(new ol.interaction.PinchRotate());
|
||||
}
|
||||
|
||||
var pinchZoom = ol.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 = ol.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({
|
||||
@@ -92,7 +92,7 @@ ol.interaction.defaults = function(opt_options) {
|
||||
}));
|
||||
}
|
||||
|
||||
var mouseWheelZoom = ol.isDef(options.mouseWheelZoom) ?
|
||||
var mouseWheelZoom = options.mouseWheelZoom !== undefined ?
|
||||
options.mouseWheelZoom : true;
|
||||
if (mouseWheelZoom) {
|
||||
interactions.push(new ol.interaction.MouseWheelZoom({
|
||||
@@ -100,7 +100,7 @@ ol.interaction.defaults = function(opt_options) {
|
||||
}));
|
||||
}
|
||||
|
||||
var shiftDragZoom = ol.isDef(options.shiftDragZoom) ?
|
||||
var shiftDragZoom = options.shiftDragZoom !== undefined ?
|
||||
options.shiftDragZoom : true;
|
||||
if (shiftDragZoom) {
|
||||
interactions.push(new ol.interaction.DragZoom());
|
||||
|
||||
@@ -35,14 +35,14 @@ ol.interaction.KeyboardPan = function(opt_options) {
|
||||
handleEvent: ol.interaction.KeyboardPan.handleEvent
|
||||
});
|
||||
|
||||
var options = ol.isDef(opt_options) ? opt_options : {};
|
||||
var options = opt_options || {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.events.ConditionType}
|
||||
*/
|
||||
this.condition_ = ol.isDef(options.condition) ?
|
||||
/** @type {ol.events.ConditionType} */ (options.condition) :
|
||||
this.condition_ = options.condition !== undefined ?
|
||||
options.condition :
|
||||
goog.functions.and(ol.events.condition.noModifierKeys,
|
||||
ol.events.condition.targetNotEditable);
|
||||
|
||||
@@ -50,15 +50,14 @@ ol.interaction.KeyboardPan = function(opt_options) {
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.duration_ = ol.isDef(options.duration) ?
|
||||
/** @type {number} */ (options.duration) : 100;
|
||||
this.duration_ = options.duration !== undefined ? options.duration : 100;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.pixelDelta_ = ol.isDef(options.pixelDelta) ?
|
||||
/** @type {number} */ (options.pixelDelta) : 128;
|
||||
this.pixelDelta_ = options.pixelDelta !== undefined ?
|
||||
options.pixelDelta : 128;
|
||||
|
||||
};
|
||||
goog.inherits(ol.interaction.KeyboardPan, ol.interaction.Interaction);
|
||||
|
||||
@@ -162,8 +162,8 @@ ol.interaction.Modify = function(options) {
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
this.pixelTolerance_ = ol.isDef(options.pixelTolerance) ?
|
||||
/** @type {number} */ (options.pixelTolerance) : 10;
|
||||
this.pixelTolerance_ = options.pixelTolerance !== undefined ?
|
||||
options.pixelTolerance : 10;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
@@ -823,9 +823,9 @@ ol.interaction.Modify.prototype.insertVertex_ = function(segmentData, vertex) {
|
||||
|
||||
this.setGeometryCoordinates_(geometry, coordinates);
|
||||
var rTree = this.rBush_;
|
||||
goog.asserts.assert(ol.isDef(segment), 'segment should be defined');
|
||||
goog.asserts.assert(segment !== undefined, 'segment should be defined');
|
||||
rTree.remove(segmentData);
|
||||
goog.asserts.assert(ol.isDef(index), 'index should be defined');
|
||||
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],
|
||||
@@ -884,13 +884,13 @@ ol.interaction.Modify.prototype.removeVertex_ = function() {
|
||||
segmentsByFeature[uid] = [left, right, index];
|
||||
}
|
||||
newSegment = segmentsByFeature[uid];
|
||||
if (ol.isDef(left)) {
|
||||
if (left !== undefined) {
|
||||
newSegment[0] = left;
|
||||
}
|
||||
if (ol.isDef(right)) {
|
||||
if (right !== undefined) {
|
||||
newSegment[1] = right;
|
||||
}
|
||||
if (ol.isDef(newSegment[0]) && ol.isDef(newSegment[1])) {
|
||||
if (newSegment[0] !== undefined && newSegment[1] !== undefined) {
|
||||
component = coordinates;
|
||||
deleted = false;
|
||||
newIndex = index - 1;
|
||||
|
||||
@@ -25,7 +25,7 @@ ol.interaction.MouseWheelZoom = function(opt_options) {
|
||||
handleEvent: ol.interaction.MouseWheelZoom.handleEvent
|
||||
});
|
||||
|
||||
var options = ol.isDef(opt_options) ? opt_options : {};
|
||||
var options = opt_options || {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -37,15 +37,13 @@ ol.interaction.MouseWheelZoom = function(opt_options) {
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.duration_ = ol.isDef(options.duration) ?
|
||||
/** @type {number} */ (options.duration) : 250;
|
||||
this.duration_ = options.duration !== undefined ? options.duration : 250;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.useAnchor_ = ol.isDef(options.useAnchor) ?
|
||||
/** @type {boolean} */ (options.useAnchor) : true;
|
||||
this.useAnchor_ = options.useAnchor !== undefined ? options.useAnchor : true;
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -92,7 +90,7 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
|
||||
|
||||
this.delta_ += mouseWheelEvent.deltaY;
|
||||
|
||||
if (!ol.isDef(this.startTime_)) {
|
||||
if (this.startTime_ === undefined) {
|
||||
this.startTime_ = goog.now();
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ ol.interaction.PinchRotate = function(opt_options) {
|
||||
handleUpEvent: ol.interaction.PinchRotate.handleUpEvent_
|
||||
});
|
||||
|
||||
var options = ol.isDef(opt_options) ? opt_options : {};
|
||||
var options = opt_options || {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -59,15 +59,13 @@ ol.interaction.PinchRotate = function(opt_options) {
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.threshold_ = ol.isDef(options.threshold) ?
|
||||
/** @type {number} */ (options.threshold) : 0.3;
|
||||
this.threshold_ = options.threshold !== undefined ? options.threshold : 0.3;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.duration_ = ol.isDef(options.duration) ?
|
||||
/** @type {number} */ (options.duration) : 250;
|
||||
this.duration_ = options.duration !== undefined ? options.duration : 250;
|
||||
|
||||
};
|
||||
goog.inherits(ol.interaction.PinchRotate, ol.interaction.Pointer);
|
||||
@@ -91,7 +89,7 @@ ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
touch1.clientY - touch0.clientY,
|
||||
touch1.clientX - touch0.clientX);
|
||||
|
||||
if (ol.isDef(this.lastAngle_)) {
|
||||
if (this.lastAngle_ !== undefined) {
|
||||
var delta = angle - this.lastAngle_;
|
||||
this.rotationDelta_ += delta;
|
||||
if (!this.rotating_ &&
|
||||
|
||||
@@ -41,8 +41,7 @@ ol.interaction.PinchZoom = function(opt_options) {
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.duration_ = ol.isDef(options.duration) ?
|
||||
/** @type {number} */ (options.duration) : 400;
|
||||
this.duration_ = options.duration !== undefined ? options.duration : 400;
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -78,7 +77,7 @@ ol.interaction.PinchZoom.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
// distance between touches
|
||||
var distance = Math.sqrt(dx * dx + dy * dy);
|
||||
|
||||
if (ol.isDef(this.lastDistance_)) {
|
||||
if (this.lastDistance_ !== undefined) {
|
||||
scaleDelta = this.lastDistance_ / distance;
|
||||
}
|
||||
this.lastDistance_ = distance;
|
||||
|
||||
@@ -115,8 +115,8 @@ ol.interaction.Snap = function(opt_options) {
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
this.pixelTolerance_ = ol.isDef(options.pixelTolerance) ?
|
||||
/** @type {number} */ (options.pixelTolerance) : 10;
|
||||
this.pixelTolerance_ = options.pixelTolerance !== undefined ?
|
||||
options.pixelTolerance : 10;
|
||||
|
||||
/**
|
||||
* @type {function(ol.interaction.Snap.SegmentDataType, ol.interaction.Snap.SegmentDataType): number}
|
||||
@@ -160,8 +160,7 @@ goog.inherits(ol.interaction.Snap, ol.interaction.Pointer);
|
||||
* @api
|
||||
*/
|
||||
ol.interaction.Snap.prototype.addFeature = function(feature, opt_listen) {
|
||||
var listen = ol.isDef(opt_listen) ?
|
||||
/** @type {boolean} */ (opt_listen) : true;
|
||||
var listen = opt_listen !== undefined ? opt_listen : true;
|
||||
var geometry = feature.getGeometry();
|
||||
var segmentWriter = this.SEGMENT_WRITERS_[geometry.getType()];
|
||||
if (segmentWriter) {
|
||||
@@ -288,8 +287,7 @@ ol.interaction.Snap.prototype.handleGeometryModify_ = function(feature, evt) {
|
||||
* @api
|
||||
*/
|
||||
ol.interaction.Snap.prototype.removeFeature = function(feature, opt_unlisten) {
|
||||
var unlisten = ol.isDef(opt_unlisten) ?
|
||||
/** @type {boolean} */ (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) {
|
||||
|
||||
Reference in New Issue
Block a user