Use ol.isDef when checking booleans
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
}));
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user