Use ol.isDef when checking booleans
This commit is contained in:
@@ -2,6 +2,7 @@ goog.provide('ol.geom.LineString');
|
|||||||
|
|
||||||
goog.require('goog.array');
|
goog.require('goog.array');
|
||||||
goog.require('goog.asserts');
|
goog.require('goog.asserts');
|
||||||
|
goog.require('ol');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.geom.GeometryLayout');
|
goog.require('ol.geom.GeometryLayout');
|
||||||
goog.require('ol.geom.GeometryType');
|
goog.require('ol.geom.GeometryType');
|
||||||
@@ -148,7 +149,8 @@ ol.geom.LineString.prototype.getCoordinateAtM = function(m, opt_extrapolate) {
|
|||||||
this.layout != ol.geom.GeometryLayout.XYZM) {
|
this.layout != ol.geom.GeometryLayout.XYZM) {
|
||||||
return null;
|
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,
|
return ol.geom.flat.lineStringCoordinateAtM(this.flatCoordinates, 0,
|
||||||
this.flatCoordinates.length, this.stride, m, extrapolate);
|
this.flatCoordinates.length, this.stride, m, extrapolate);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
goog.provide('ol.interaction.DragRotateAndZoom');
|
goog.provide('ol.interaction.DragRotateAndZoom');
|
||||||
|
|
||||||
goog.require('goog.math.Vec2');
|
goog.require('goog.math.Vec2');
|
||||||
|
goog.require('ol');
|
||||||
goog.require('ol.ViewHint');
|
goog.require('ol.ViewHint');
|
||||||
goog.require('ol.events.ConditionType');
|
goog.require('ol.events.ConditionType');
|
||||||
goog.require('ol.events.condition');
|
goog.require('ol.events.condition');
|
||||||
@@ -89,17 +90,17 @@ ol.interaction.DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) {
|
|||||||
var magnitude = delta.magnitude();
|
var magnitude = delta.magnitude();
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
map.render();
|
map.render();
|
||||||
if (this.lastAngle_ !== undefined) {
|
if (ol.isDef(this.lastAngle_)) {
|
||||||
var angleDelta = theta - this.lastAngle_;
|
var angleDelta = theta - this.lastAngle_;
|
||||||
ol.interaction.Interaction.rotateWithoutConstraints(
|
ol.interaction.Interaction.rotateWithoutConstraints(
|
||||||
map, view, view.getRotation() - angleDelta);
|
map, view, view.getRotation() - angleDelta);
|
||||||
}
|
}
|
||||||
this.lastAngle_ = theta;
|
this.lastAngle_ = theta;
|
||||||
if (this.lastMagnitude_ !== undefined) {
|
if (ol.isDef(this.lastMagnitude_)) {
|
||||||
var resolution = this.lastMagnitude_ * (view.getResolution() / magnitude);
|
var resolution = this.lastMagnitude_ * (view.getResolution() / magnitude);
|
||||||
ol.interaction.Interaction.zoomWithoutConstraints(map, view, resolution);
|
ol.interaction.Interaction.zoomWithoutConstraints(map, view, resolution);
|
||||||
}
|
}
|
||||||
if (this.lastMagnitude_ !== undefined) {
|
if (ol.isDef(this.lastMagnitude_)) {
|
||||||
this.lastScaleDelta_ = this.lastMagnitude_ / magnitude;
|
this.lastScaleDelta_ = this.lastMagnitude_ / magnitude;
|
||||||
}
|
}
|
||||||
this.lastMagnitude_ = magnitude;
|
this.lastMagnitude_ = magnitude;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
goog.provide('ol.interaction.DragRotate');
|
goog.provide('ol.interaction.DragRotate');
|
||||||
|
|
||||||
|
goog.require('ol');
|
||||||
goog.require('ol.ViewHint');
|
goog.require('ol.ViewHint');
|
||||||
goog.require('ol.events.ConditionType');
|
goog.require('ol.events.ConditionType');
|
||||||
goog.require('ol.events.condition');
|
goog.require('ol.events.condition');
|
||||||
@@ -68,7 +69,7 @@ ol.interaction.DragRotate.handleDragEvent_ = function(mapBrowserEvent) {
|
|||||||
var offset = mapBrowserEvent.pixel;
|
var offset = mapBrowserEvent.pixel;
|
||||||
var theta =
|
var theta =
|
||||||
Math.atan2(size[1] / 2 - offset[1], offset[0] - size[0] / 2);
|
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 delta = theta - this.lastAngle_;
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
var rotation = view.getRotation();
|
var rotation = view.getRotation();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
goog.provide('ol.interaction.Interaction');
|
goog.provide('ol.interaction.Interaction');
|
||||||
goog.provide('ol.interaction.InteractionProperty');
|
goog.provide('ol.interaction.InteractionProperty');
|
||||||
|
|
||||||
|
goog.require('ol');
|
||||||
goog.require('ol.MapBrowserEvent');
|
goog.require('ol.MapBrowserEvent');
|
||||||
goog.require('ol.Object');
|
goog.require('ol.Object');
|
||||||
goog.require('ol.animation');
|
goog.require('ol.animation');
|
||||||
@@ -149,7 +150,7 @@ ol.interaction.Interaction.rotateWithoutConstraints =
|
|||||||
if (goog.isDefAndNotNull(rotation)) {
|
if (goog.isDefAndNotNull(rotation)) {
|
||||||
var currentRotation = view.getRotation();
|
var currentRotation = view.getRotation();
|
||||||
var currentCenter = view.getCenter();
|
var currentCenter = view.getCenter();
|
||||||
if (currentRotation !== undefined && currentCenter &&
|
if (ol.isDef(currentRotation) && currentCenter &&
|
||||||
opt_duration && opt_duration > 0) {
|
opt_duration && opt_duration > 0) {
|
||||||
map.beforeRender(ol.animation.rotate({
|
map.beforeRender(ol.animation.rotate({
|
||||||
rotation: currentRotation,
|
rotation: currentRotation,
|
||||||
@@ -220,10 +221,10 @@ ol.interaction.Interaction.zoomWithoutConstraints =
|
|||||||
if (goog.isDefAndNotNull(resolution)) {
|
if (goog.isDefAndNotNull(resolution)) {
|
||||||
var currentResolution = view.getResolution();
|
var currentResolution = view.getResolution();
|
||||||
var currentCenter = view.getCenter();
|
var currentCenter = view.getCenter();
|
||||||
if (currentResolution !== undefined && currentCenter &&
|
if (ol.isDef(currentResolution) && currentCenter &&
|
||||||
opt_duration && opt_duration > 0) {
|
opt_duration && opt_duration > 0) {
|
||||||
map.beforeRender(ol.animation.zoom({
|
map.beforeRender(ol.animation.zoom({
|
||||||
resolution: currentResolution,
|
resolution: /** @type {number} */ (currentResolution),
|
||||||
duration: opt_duration,
|
duration: opt_duration,
|
||||||
easing: ol.easing.easeOut
|
easing: ol.easing.easeOut
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
goog.provide('ol.interaction');
|
goog.provide('ol.interaction');
|
||||||
|
|
||||||
|
goog.require('ol');
|
||||||
goog.require('ol.Collection');
|
goog.require('ol.Collection');
|
||||||
goog.require('ol.Kinetic');
|
goog.require('ol.Kinetic');
|
||||||
goog.require('ol.interaction.DoubleClickZoom');
|
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 kinetic = new ol.Kinetic(-0.005, 0.05, 100);
|
||||||
|
|
||||||
var altShiftDragRotate = options.altShiftDragRotate !== undefined ?
|
var altShiftDragRotate = ol.isDef(options.altShiftDragRotate) ?
|
||||||
options.altShiftDragRotate : true;
|
options.altShiftDragRotate : true;
|
||||||
if (altShiftDragRotate) {
|
if (altShiftDragRotate) {
|
||||||
interactions.push(new ol.interaction.DragRotate());
|
interactions.push(new ol.interaction.DragRotate());
|
||||||
}
|
}
|
||||||
|
|
||||||
var doubleClickZoom = options.doubleClickZoom !== undefined ?
|
var doubleClickZoom = ol.isDef(options.doubleClickZoom) ?
|
||||||
options.doubleClickZoom : true;
|
options.doubleClickZoom : true;
|
||||||
if (doubleClickZoom) {
|
if (doubleClickZoom) {
|
||||||
interactions.push(new ol.interaction.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) {
|
if (dragPan) {
|
||||||
interactions.push(new ol.interaction.DragPan({
|
interactions.push(new ol.interaction.DragPan({
|
||||||
kinetic: kinetic
|
kinetic: kinetic
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
var pinchRotate = options.pinchRotate !== undefined ? options.pinchRotate :
|
var pinchRotate = ol.isDef(options.pinchRotate) ? options.pinchRotate :
|
||||||
true;
|
true;
|
||||||
if (pinchRotate) {
|
if (pinchRotate) {
|
||||||
interactions.push(new ol.interaction.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) {
|
if (pinchZoom) {
|
||||||
interactions.push(new ol.interaction.PinchZoom({
|
interactions.push(new ol.interaction.PinchZoom({
|
||||||
duration: options.zoomDuration
|
duration: options.zoomDuration
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
var keyboard = options.keyboard !== undefined ? options.keyboard : true;
|
var keyboard = ol.isDef(options.keyboard) ? options.keyboard : true;
|
||||||
if (keyboard) {
|
if (keyboard) {
|
||||||
interactions.push(new ol.interaction.KeyboardPan());
|
interactions.push(new ol.interaction.KeyboardPan());
|
||||||
interactions.push(new ol.interaction.KeyboardZoom({
|
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;
|
options.mouseWheelZoom : true;
|
||||||
if (mouseWheelZoom) {
|
if (mouseWheelZoom) {
|
||||||
interactions.push(new ol.interaction.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;
|
options.shiftDragZoom : true;
|
||||||
if (shiftDragZoom) {
|
if (shiftDragZoom) {
|
||||||
interactions.push(new ol.interaction.DragZoom());
|
interactions.push(new ol.interaction.DragZoom());
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ goog.require('goog.events');
|
|||||||
goog.require('goog.events.Event');
|
goog.require('goog.events.Event');
|
||||||
goog.require('goog.events.EventType');
|
goog.require('goog.events.EventType');
|
||||||
goog.require('goog.functions');
|
goog.require('goog.functions');
|
||||||
|
goog.require('ol');
|
||||||
goog.require('ol.Collection');
|
goog.require('ol.Collection');
|
||||||
goog.require('ol.CollectionEventType');
|
goog.require('ol.CollectionEventType');
|
||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
@@ -882,13 +883,13 @@ ol.interaction.Modify.prototype.removeVertex_ = function() {
|
|||||||
segmentsByFeature[uid] = [left, right, index];
|
segmentsByFeature[uid] = [left, right, index];
|
||||||
}
|
}
|
||||||
newSegment = segmentsByFeature[uid];
|
newSegment = segmentsByFeature[uid];
|
||||||
if (left !== undefined) {
|
if (ol.isDef(left)) {
|
||||||
newSegment[0] = left;
|
newSegment[0] = left;
|
||||||
}
|
}
|
||||||
if (right !== undefined) {
|
if (ol.isDef(right)) {
|
||||||
newSegment[1] = right;
|
newSegment[1] = right;
|
||||||
}
|
}
|
||||||
if (newSegment[0] !== undefined && newSegment[1] !== undefined) {
|
if (ol.isDef(newSegment[0]) && ol.isDef(newSegment[1])) {
|
||||||
component = coordinates;
|
component = coordinates;
|
||||||
deleted = false;
|
deleted = false;
|
||||||
newIndex = index - 1;
|
newIndex = index - 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user