Remove goog.isNull in interaction classes
This commit is contained in:
@@ -56,7 +56,7 @@ ol.interaction.DoubleClickZoom.handleEvent = function(mapBrowserEvent) {
|
|||||||
var anchor = mapBrowserEvent.coordinate;
|
var anchor = mapBrowserEvent.coordinate;
|
||||||
var delta = browserEvent.shiftKey ? -this.delta_ : this.delta_;
|
var delta = browserEvent.shiftKey ? -this.delta_ : this.delta_;
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
goog.asserts.assert(!goog.isNull(view), 'view should not be null');
|
goog.asserts.assert(view, 'map must have a view');
|
||||||
ol.interaction.Interaction.zoomByDelta(
|
ol.interaction.Interaction.zoomByDelta(
|
||||||
map, view, delta, anchor, this.duration_);
|
map, view, delta, anchor, this.duration_);
|
||||||
mapBrowserEvent.preventDefault();
|
mapBrowserEvent.preventDefault();
|
||||||
|
|||||||
@@ -98,11 +98,11 @@ ol.interaction.DragAndDrop.prototype.handleDrop_ = function(event) {
|
|||||||
*/
|
*/
|
||||||
ol.interaction.DragAndDrop.prototype.handleResult_ = function(file, result) {
|
ol.interaction.DragAndDrop.prototype.handleResult_ = function(file, result) {
|
||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
goog.asserts.assert(!goog.isNull(map), 'map should not be null');
|
goog.asserts.assert(map, 'map must be set');
|
||||||
var projection = this.projection_;
|
var projection = this.projection_;
|
||||||
if (goog.isNull(projection)) {
|
if (!projection) {
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
goog.asserts.assert(!goog.isNull(view), 'view should not be null');
|
goog.asserts.assert(view, 'map must have view');
|
||||||
projection = view.getProjection();
|
projection = view.getProjection();
|
||||||
goog.asserts.assert(projection !== undefined,
|
goog.asserts.assert(projection !== undefined,
|
||||||
'projection should be defined');
|
'projection should be defined');
|
||||||
@@ -114,7 +114,7 @@ ol.interaction.DragAndDrop.prototype.handleResult_ = function(file, result) {
|
|||||||
var formatConstructor = formatConstructors[i];
|
var formatConstructor = formatConstructors[i];
|
||||||
var format = new formatConstructor();
|
var format = new formatConstructor();
|
||||||
var readFeatures = this.tryReadFeatures_(format, result);
|
var readFeatures = this.tryReadFeatures_(format, result);
|
||||||
if (!goog.isNull(readFeatures)) {
|
if (readFeatures) {
|
||||||
var featureProjection = format.readProjection(result);
|
var featureProjection = format.readProjection(result);
|
||||||
var transform = ol.proj.getTransform(featureProjection, projection);
|
var transform = ol.proj.getTransform(featureProjection, projection);
|
||||||
var j, jj;
|
var j, jj;
|
||||||
@@ -154,14 +154,14 @@ ol.interaction.DragAndDrop.prototype.setMap = function(map) {
|
|||||||
goog.events.unlistenByKey(this.dropListenKey_);
|
goog.events.unlistenByKey(this.dropListenKey_);
|
||||||
this.dropListenKey_ = undefined;
|
this.dropListenKey_ = undefined;
|
||||||
}
|
}
|
||||||
if (!goog.isNull(this.fileDropHandler_)) {
|
if (this.fileDropHandler_) {
|
||||||
goog.dispose(this.fileDropHandler_);
|
goog.dispose(this.fileDropHandler_);
|
||||||
this.fileDropHandler_ = null;
|
this.fileDropHandler_ = null;
|
||||||
}
|
}
|
||||||
goog.asserts.assert(this.dropListenKey_ === undefined,
|
goog.asserts.assert(this.dropListenKey_ === undefined,
|
||||||
'this.dropListenKey_ should be undefined');
|
'this.dropListenKey_ should be undefined');
|
||||||
goog.base(this, 'setMap', map);
|
goog.base(this, 'setMap', map);
|
||||||
if (!goog.isNull(map)) {
|
if (map) {
|
||||||
this.fileDropHandler_ = new goog.events.FileDropHandler(map.getViewport());
|
this.fileDropHandler_ = new goog.events.FileDropHandler(map.getViewport());
|
||||||
this.dropListenKey_ = goog.events.listen(
|
this.dropListenKey_ = goog.events.listen(
|
||||||
this.fileDropHandler_, goog.events.FileDropHandler.EventType.DROP,
|
this.fileDropHandler_, goog.events.FileDropHandler.EventType.DROP,
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ ol.interaction.DragPan.handleDragEvent_ = function(mapBrowserEvent) {
|
|||||||
if (this.kinetic_) {
|
if (this.kinetic_) {
|
||||||
this.kinetic_.update(centroid[0], centroid[1]);
|
this.kinetic_.update(centroid[0], centroid[1]);
|
||||||
}
|
}
|
||||||
if (!goog.isNull(this.lastCentroid)) {
|
if (this.lastCentroid) {
|
||||||
var deltaX = this.lastCentroid[0] - centroid[0];
|
var deltaX = this.lastCentroid[0] - centroid[0];
|
||||||
var deltaY = centroid[1] - this.lastCentroid[1];
|
var deltaY = centroid[1] - this.lastCentroid[1];
|
||||||
var map = mapBrowserEvent.map;
|
var map = mapBrowserEvent.map;
|
||||||
@@ -145,7 +145,7 @@ ol.interaction.DragPan.handleDownEvent_ = function(mapBrowserEvent) {
|
|||||||
view.setHint(ol.ViewHint.INTERACTING, 1);
|
view.setHint(ol.ViewHint.INTERACTING, 1);
|
||||||
}
|
}
|
||||||
map.render();
|
map.render();
|
||||||
if (!goog.isNull(this.kineticPreRenderFn_) &&
|
if (this.kineticPreRenderFn_ &&
|
||||||
map.removePreRenderFunction(this.kineticPreRenderFn_)) {
|
map.removePreRenderFunction(this.kineticPreRenderFn_)) {
|
||||||
view.setCenter(mapBrowserEvent.frameState.viewState.center);
|
view.setCenter(mapBrowserEvent.frameState.viewState.center);
|
||||||
this.kineticPreRenderFn_ = null;
|
this.kineticPreRenderFn_ = null;
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ ol.interaction.DragZoom.prototype.onBoxEnd = function() {
|
|||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
|
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
goog.asserts.assert(!goog.isNull(view), 'view should not be null');
|
goog.asserts.assert(view, 'map must have view');
|
||||||
|
|
||||||
var size = map.getSize();
|
var size = map.getSize();
|
||||||
goog.asserts.assert(size !== undefined, 'size should be defined');
|
goog.asserts.assert(size !== undefined, 'size should be defined');
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ ol.interaction.Draw.handleDownEvent_ = function(event) {
|
|||||||
this.freehandCondition_(event)) {
|
this.freehandCondition_(event)) {
|
||||||
this.downPx_ = event.pixel;
|
this.downPx_ = event.pixel;
|
||||||
this.freehand_ = true;
|
this.freehand_ = true;
|
||||||
if (goog.isNull(this.finishCoordinate_)) {
|
if (!this.finishCoordinate_) {
|
||||||
this.startDrawing_(event);
|
this.startDrawing_(event);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -393,7 +393,7 @@ ol.interaction.Draw.handleUpEvent_ = function(event) {
|
|||||||
var pass = true;
|
var pass = true;
|
||||||
if (squaredDistance <= this.squaredClickTolerance_) {
|
if (squaredDistance <= this.squaredClickTolerance_) {
|
||||||
this.handlePointerMove_(event);
|
this.handlePointerMove_(event);
|
||||||
if (goog.isNull(this.finishCoordinate_)) {
|
if (!this.finishCoordinate_) {
|
||||||
this.startDrawing_(event);
|
this.startDrawing_(event);
|
||||||
if (this.mode_ === ol.interaction.DrawMode.POINT) {
|
if (this.mode_ === ol.interaction.DrawMode.POINT) {
|
||||||
this.finishDrawing();
|
this.finishDrawing();
|
||||||
@@ -418,7 +418,7 @@ ol.interaction.Draw.handleUpEvent_ = function(event) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.interaction.Draw.prototype.handlePointerMove_ = function(event) {
|
ol.interaction.Draw.prototype.handlePointerMove_ = function(event) {
|
||||||
if (!goog.isNull(this.finishCoordinate_)) {
|
if (this.finishCoordinate_) {
|
||||||
this.modifyDrawing_(event);
|
this.modifyDrawing_(event);
|
||||||
} else {
|
} else {
|
||||||
this.createOrUpdateSketchPoint_(event);
|
this.createOrUpdateSketchPoint_(event);
|
||||||
@@ -435,7 +435,7 @@ ol.interaction.Draw.prototype.handlePointerMove_ = function(event) {
|
|||||||
*/
|
*/
|
||||||
ol.interaction.Draw.prototype.atFinish_ = function(event) {
|
ol.interaction.Draw.prototype.atFinish_ = function(event) {
|
||||||
var at = false;
|
var at = false;
|
||||||
if (!goog.isNull(this.sketchFeature_)) {
|
if (this.sketchFeature_) {
|
||||||
var potentiallyDone = false;
|
var potentiallyDone = false;
|
||||||
var potentiallyFinishCoordinates = [this.finishCoordinate_];
|
var potentiallyFinishCoordinates = [this.finishCoordinate_];
|
||||||
if (this.mode_ === ol.interaction.DrawMode.LINE_STRING) {
|
if (this.mode_ === ol.interaction.DrawMode.LINE_STRING) {
|
||||||
@@ -474,7 +474,7 @@ ol.interaction.Draw.prototype.atFinish_ = function(event) {
|
|||||||
*/
|
*/
|
||||||
ol.interaction.Draw.prototype.createOrUpdateSketchPoint_ = function(event) {
|
ol.interaction.Draw.prototype.createOrUpdateSketchPoint_ = function(event) {
|
||||||
var coordinates = event.coordinate.slice();
|
var coordinates = event.coordinate.slice();
|
||||||
if (goog.isNull(this.sketchPoint_)) {
|
if (!this.sketchPoint_) {
|
||||||
this.sketchPoint_ = new ol.Feature(new ol.geom.Point(coordinates));
|
this.sketchPoint_ = new ol.Feature(new ol.geom.Point(coordinates));
|
||||||
this.updateSketchFeatures_();
|
this.updateSketchFeatures_();
|
||||||
} else {
|
} else {
|
||||||
@@ -505,7 +505,7 @@ ol.interaction.Draw.prototype.startDrawing_ = function(event) {
|
|||||||
this.sketchLineCoords_ = this.sketchCoords_;
|
this.sketchLineCoords_ = this.sketchCoords_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!goog.isNull(this.sketchLineCoords_)) {
|
if (this.sketchLineCoords_) {
|
||||||
this.sketchLine_ = new ol.Feature(
|
this.sketchLine_ = new ol.Feature(
|
||||||
new ol.geom.LineString(this.sketchLineCoords_));
|
new ol.geom.LineString(this.sketchLineCoords_));
|
||||||
}
|
}
|
||||||
@@ -548,10 +548,9 @@ ol.interaction.Draw.prototype.modifyDrawing_ = function(event) {
|
|||||||
}
|
}
|
||||||
last[0] = coordinate[0];
|
last[0] = coordinate[0];
|
||||||
last[1] = coordinate[1];
|
last[1] = coordinate[1];
|
||||||
goog.asserts.assert(!goog.isNull(this.sketchCoords_),
|
goog.asserts.assert(this.sketchCoords_, 'sketchCoords_ expected');
|
||||||
'sketchCoords_ must not be null');
|
|
||||||
this.geometryFunction_(this.sketchCoords_, geometry);
|
this.geometryFunction_(this.sketchCoords_, geometry);
|
||||||
if (!goog.isNull(this.sketchPoint_)) {
|
if (this.sketchPoint_) {
|
||||||
var sketchPointGeom = this.sketchPoint_.getGeometry();
|
var sketchPointGeom = this.sketchPoint_.getGeometry();
|
||||||
goog.asserts.assertInstanceof(sketchPointGeom, ol.geom.Point,
|
goog.asserts.assertInstanceof(sketchPointGeom, ol.geom.Point,
|
||||||
'sketchPointGeom should be an ol.geom.Point');
|
'sketchPointGeom should be an ol.geom.Point');
|
||||||
@@ -560,7 +559,7 @@ ol.interaction.Draw.prototype.modifyDrawing_ = function(event) {
|
|||||||
var sketchLineGeom;
|
var sketchLineGeom;
|
||||||
if (geometry instanceof ol.geom.Polygon &&
|
if (geometry instanceof ol.geom.Polygon &&
|
||||||
this.mode_ !== ol.interaction.DrawMode.POLYGON) {
|
this.mode_ !== ol.interaction.DrawMode.POLYGON) {
|
||||||
if (goog.isNull(this.sketchLine_)) {
|
if (!this.sketchLine_) {
|
||||||
this.sketchLine_ = new ol.Feature(new ol.geom.LineString(null));
|
this.sketchLine_ = new ol.Feature(new ol.geom.LineString(null));
|
||||||
}
|
}
|
||||||
var ring = geometry.getLinearRing(0);
|
var ring = geometry.getLinearRing(0);
|
||||||
@@ -569,7 +568,7 @@ ol.interaction.Draw.prototype.modifyDrawing_ = function(event) {
|
|||||||
'sketchLineGeom must be an ol.geom.LineString');
|
'sketchLineGeom must be an ol.geom.LineString');
|
||||||
sketchLineGeom.setFlatCoordinates(
|
sketchLineGeom.setFlatCoordinates(
|
||||||
ring.getLayout(), ring.getFlatCoordinates());
|
ring.getLayout(), ring.getFlatCoordinates());
|
||||||
} else if (!goog.isNull(this.sketchLineCoords_)) {
|
} else if (this.sketchLineCoords_) {
|
||||||
sketchLineGeom = this.sketchLine_.getGeometry();
|
sketchLineGeom = this.sketchLine_.getGeometry();
|
||||||
goog.asserts.assertInstanceof(sketchLineGeom, ol.geom.LineString,
|
goog.asserts.assertInstanceof(sketchLineGeom, ol.geom.LineString,
|
||||||
'sketchLineGeom must be an ol.geom.LineString');
|
'sketchLineGeom must be an ol.geom.LineString');
|
||||||
@@ -652,8 +651,7 @@ ol.interaction.Draw.prototype.removeLastPoint = function() {
|
|||||||
*/
|
*/
|
||||||
ol.interaction.Draw.prototype.finishDrawing = function() {
|
ol.interaction.Draw.prototype.finishDrawing = function() {
|
||||||
var sketchFeature = this.abortDrawing_();
|
var sketchFeature = this.abortDrawing_();
|
||||||
goog.asserts.assert(!goog.isNull(sketchFeature),
|
goog.asserts.assert(sketchFeature, 'sketchFeature expected to be truthy');
|
||||||
'sketchFeature should not be null');
|
|
||||||
var coordinates = this.sketchCoords_;
|
var coordinates = this.sketchCoords_;
|
||||||
var geometry = sketchFeature.getGeometry();
|
var geometry = sketchFeature.getGeometry();
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.SimpleGeometry,
|
goog.asserts.assertInstanceof(geometry, ol.geom.SimpleGeometry,
|
||||||
@@ -685,10 +683,10 @@ ol.interaction.Draw.prototype.finishDrawing = function() {
|
|||||||
ol.interaction.DrawEventType.DRAWEND, sketchFeature));
|
ol.interaction.DrawEventType.DRAWEND, sketchFeature));
|
||||||
|
|
||||||
// Then insert feature
|
// Then insert feature
|
||||||
if (!goog.isNull(this.features_)) {
|
if (this.features_) {
|
||||||
this.features_.push(sketchFeature);
|
this.features_.push(sketchFeature);
|
||||||
}
|
}
|
||||||
if (!goog.isNull(this.source_)) {
|
if (this.source_) {
|
||||||
this.source_.addFeature(sketchFeature);
|
this.source_.addFeature(sketchFeature);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -702,7 +700,7 @@ ol.interaction.Draw.prototype.finishDrawing = function() {
|
|||||||
ol.interaction.Draw.prototype.abortDrawing_ = function() {
|
ol.interaction.Draw.prototype.abortDrawing_ = function() {
|
||||||
this.finishCoordinate_ = null;
|
this.finishCoordinate_ = null;
|
||||||
var sketchFeature = this.sketchFeature_;
|
var sketchFeature = this.sketchFeature_;
|
||||||
if (!goog.isNull(sketchFeature)) {
|
if (sketchFeature) {
|
||||||
this.sketchFeature_ = null;
|
this.sketchFeature_ = null;
|
||||||
this.sketchPoint_ = null;
|
this.sketchPoint_ = null;
|
||||||
this.sketchLine_ = null;
|
this.sketchLine_ = null;
|
||||||
@@ -750,13 +748,13 @@ ol.interaction.Draw.prototype.shouldStopEvent = goog.functions.FALSE;
|
|||||||
*/
|
*/
|
||||||
ol.interaction.Draw.prototype.updateSketchFeatures_ = function() {
|
ol.interaction.Draw.prototype.updateSketchFeatures_ = function() {
|
||||||
var sketchFeatures = [];
|
var sketchFeatures = [];
|
||||||
if (!goog.isNull(this.sketchFeature_)) {
|
if (this.sketchFeature_) {
|
||||||
sketchFeatures.push(this.sketchFeature_);
|
sketchFeatures.push(this.sketchFeature_);
|
||||||
}
|
}
|
||||||
if (!goog.isNull(this.sketchLine_)) {
|
if (this.sketchLine_) {
|
||||||
sketchFeatures.push(this.sketchLine_);
|
sketchFeatures.push(this.sketchLine_);
|
||||||
}
|
}
|
||||||
if (!goog.isNull(this.sketchPoint_)) {
|
if (this.sketchPoint_) {
|
||||||
sketchFeatures.push(this.sketchPoint_);
|
sketchFeatures.push(this.sketchPoint_);
|
||||||
}
|
}
|
||||||
var overlaySource = this.overlay_.getSource();
|
var overlaySource = this.overlay_.getSource();
|
||||||
@@ -771,7 +769,7 @@ ol.interaction.Draw.prototype.updateSketchFeatures_ = function() {
|
|||||||
ol.interaction.Draw.prototype.updateState_ = function() {
|
ol.interaction.Draw.prototype.updateState_ = function() {
|
||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
var active = this.getActive();
|
var active = this.getActive();
|
||||||
if (goog.isNull(map) || !active) {
|
if (!map || !active) {
|
||||||
this.abortDrawing_();
|
this.abortDrawing_();
|
||||||
}
|
}
|
||||||
this.overlay_.setMap(active ? map : null);
|
this.overlay_.setMap(active ? map : null);
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ ol.interaction.KeyboardPan.handleEvent = function(mapBrowserEvent) {
|
|||||||
keyCode == goog.events.KeyCodes.UP)) {
|
keyCode == goog.events.KeyCodes.UP)) {
|
||||||
var map = mapBrowserEvent.map;
|
var map = mapBrowserEvent.map;
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
goog.asserts.assert(!goog.isNull(view), 'view should not be null');
|
goog.asserts.assert(view, 'map must have view');
|
||||||
var mapUnitsDelta = view.getResolution() * this.pixelDelta_;
|
var mapUnitsDelta = view.getResolution() * this.pixelDelta_;
|
||||||
var deltaX = 0, deltaY = 0;
|
var deltaX = 0, deltaY = 0;
|
||||||
if (keyCode == goog.events.KeyCodes.DOWN) {
|
if (keyCode == goog.events.KeyCodes.DOWN) {
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ ol.interaction.KeyboardZoom.handleEvent = function(mapBrowserEvent) {
|
|||||||
var delta = (charCode == '+'.charCodeAt(0)) ? this.delta_ : -this.delta_;
|
var delta = (charCode == '+'.charCodeAt(0)) ? this.delta_ : -this.delta_;
|
||||||
map.render();
|
map.render();
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
goog.asserts.assert(!goog.isNull(view), 'view should not be null');
|
goog.asserts.assert(view, 'map must have view');
|
||||||
ol.interaction.Interaction.zoomByDelta(
|
ol.interaction.Interaction.zoomByDelta(
|
||||||
map, view, delta, undefined, this.duration_);
|
map, view, delta, undefined, this.duration_);
|
||||||
mapBrowserEvent.preventDefault();
|
mapBrowserEvent.preventDefault();
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ ol.interaction.Modify.prototype.addFeature_ = function(feature) {
|
|||||||
this.SEGMENT_WRITERS_[geometry.getType()].call(this, feature, geometry);
|
this.SEGMENT_WRITERS_[geometry.getType()].call(this, feature, geometry);
|
||||||
}
|
}
|
||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
if (!goog.isNull(map)) {
|
if (map) {
|
||||||
this.handlePointerAtPixel_(this.lastPixel_, map);
|
this.handlePointerAtPixel_(this.lastPixel_, map);
|
||||||
}
|
}
|
||||||
goog.events.listen(feature, goog.events.EventType.CHANGE,
|
goog.events.listen(feature, goog.events.EventType.CHANGE,
|
||||||
@@ -259,8 +259,7 @@ ol.interaction.Modify.prototype.removeFeature_ = function(feature) {
|
|||||||
this.removeFeatureSegmentData_(feature);
|
this.removeFeatureSegmentData_(feature);
|
||||||
// Remove the vertex feature if the collection of canditate features
|
// Remove the vertex feature if the collection of canditate features
|
||||||
// is empty.
|
// is empty.
|
||||||
if (!goog.isNull(this.vertexFeature_) &&
|
if (this.vertexFeature_ && this.features_.getLength() === 0) {
|
||||||
this.features_.getLength() === 0) {
|
|
||||||
this.overlay_.getSource().removeFeature(this.vertexFeature_);
|
this.overlay_.getSource().removeFeature(this.vertexFeature_);
|
||||||
this.vertexFeature_ = null;
|
this.vertexFeature_ = null;
|
||||||
}
|
}
|
||||||
@@ -501,7 +500,7 @@ ol.interaction.Modify.prototype.writeGeometryCollectionGeometry_ =
|
|||||||
ol.interaction.Modify.prototype.createOrUpdateVertexFeature_ =
|
ol.interaction.Modify.prototype.createOrUpdateVertexFeature_ =
|
||||||
function(coordinates) {
|
function(coordinates) {
|
||||||
var vertexFeature = this.vertexFeature_;
|
var vertexFeature = this.vertexFeature_;
|
||||||
if (goog.isNull(vertexFeature)) {
|
if (!vertexFeature) {
|
||||||
vertexFeature = new ol.Feature(new ol.geom.Point(coordinates));
|
vertexFeature = new ol.Feature(new ol.geom.Point(coordinates));
|
||||||
this.vertexFeature_ = vertexFeature;
|
this.vertexFeature_ = vertexFeature;
|
||||||
this.overlay_.getSource().addFeature(vertexFeature);
|
this.overlay_.getSource().addFeature(vertexFeature);
|
||||||
@@ -534,7 +533,7 @@ ol.interaction.Modify.handleDownEvent_ = function(evt) {
|
|||||||
this.handlePointerAtPixel_(evt.pixel, evt.map);
|
this.handlePointerAtPixel_(evt.pixel, evt.map);
|
||||||
this.dragSegments_ = [];
|
this.dragSegments_ = [];
|
||||||
var vertexFeature = this.vertexFeature_;
|
var vertexFeature = this.vertexFeature_;
|
||||||
if (!goog.isNull(vertexFeature)) {
|
if (vertexFeature) {
|
||||||
var insertVertices = [];
|
var insertVertices = [];
|
||||||
var geometry = /** @type {ol.geom.Point} */ (vertexFeature.getGeometry());
|
var geometry = /** @type {ol.geom.Point} */ (vertexFeature.getGeometry());
|
||||||
var vertex = geometry.getCoordinates();
|
var vertex = geometry.getCoordinates();
|
||||||
@@ -584,7 +583,7 @@ ol.interaction.Modify.handleDownEvent_ = function(evt) {
|
|||||||
new ol.interaction.ModifyEvent(ol.ModifyEventType.MODIFYSTART,
|
new ol.interaction.ModifyEvent(ol.ModifyEventType.MODIFYSTART,
|
||||||
this.features_, evt));
|
this.features_, evt));
|
||||||
}
|
}
|
||||||
return !goog.isNull(this.vertexFeature_);
|
return this.vertexFeature_ !== null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -678,8 +677,7 @@ ol.interaction.Modify.handleEvent = function(mapBrowserEvent) {
|
|||||||
!this.handlingDownUpSequence) {
|
!this.handlingDownUpSequence) {
|
||||||
this.handlePointerMove_(mapBrowserEvent);
|
this.handlePointerMove_(mapBrowserEvent);
|
||||||
}
|
}
|
||||||
if (!goog.isNull(this.vertexFeature_) &&
|
if (this.vertexFeature_ && this.deleteCondition_(mapBrowserEvent)) {
|
||||||
this.deleteCondition_(mapBrowserEvent)) {
|
|
||||||
if (mapBrowserEvent.type != ol.MapBrowserEvent.EventType.SINGLECLICK ||
|
if (mapBrowserEvent.type != ol.MapBrowserEvent.EventType.SINGLECLICK ||
|
||||||
!this.ignoreNextSingleClick_) {
|
!this.ignoreNextSingleClick_) {
|
||||||
var geometry = this.vertexFeature_.getGeometry();
|
var geometry = this.vertexFeature_.getGeometry();
|
||||||
@@ -768,7 +766,7 @@ ol.interaction.Modify.prototype.handlePointerAtPixel_ = function(pixel, map) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!goog.isNull(this.vertexFeature_)) {
|
if (this.vertexFeature_) {
|
||||||
this.overlay_.getSource().removeFeature(this.vertexFeature_);
|
this.overlay_.getSource().removeFeature(this.vertexFeature_);
|
||||||
this.vertexFeature_ = null;
|
this.vertexFeature_ = null;
|
||||||
}
|
}
|
||||||
@@ -940,7 +938,7 @@ ol.interaction.Modify.prototype.removeVertex_ = function() {
|
|||||||
newSegmentData);
|
newSegmentData);
|
||||||
this.updateSegmentIndices_(geometry, index, segmentData.depth, -1);
|
this.updateSegmentIndices_(geometry, index, segmentData.depth, -1);
|
||||||
|
|
||||||
if (!goog.isNull(this.vertexFeature_)) {
|
if (this.vertexFeature_) {
|
||||||
this.overlay_.getSource().removeFeature(this.vertexFeature_);
|
this.overlay_.getSource().removeFeature(this.vertexFeature_);
|
||||||
this.vertexFeature_ = null;
|
this.vertexFeature_ = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ ol.interaction.MouseWheelZoom.prototype.doZoom_ = function(map) {
|
|||||||
var delta = ol.math.clamp(this.delta_, -maxDelta, maxDelta);
|
var delta = ol.math.clamp(this.delta_, -maxDelta, maxDelta);
|
||||||
|
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
goog.asserts.assert(!goog.isNull(view), 'view should not be null');
|
goog.asserts.assert(view, 'map must have view');
|
||||||
|
|
||||||
map.render();
|
map.render();
|
||||||
ol.interaction.Interaction.zoomByDelta(map, view, -delta, this.lastAnchor_,
|
ol.interaction.Interaction.zoomByDelta(map, view, -delta, this.lastAnchor_,
|
||||||
|
|||||||
@@ -205,9 +205,9 @@ ol.interaction.Snap.prototype.forEachFeatureRemove_ = function(feature) {
|
|||||||
*/
|
*/
|
||||||
ol.interaction.Snap.prototype.getFeatures_ = function() {
|
ol.interaction.Snap.prototype.getFeatures_ = function() {
|
||||||
var features;
|
var features;
|
||||||
if (!goog.isNull(this.features_)) {
|
if (this.features_) {
|
||||||
features = this.features_;
|
features = this.features_;
|
||||||
} else if (!goog.isNull(this.source_)) {
|
} else if (this.source_) {
|
||||||
features = this.source_.getFeatures();
|
features = this.source_.getFeatures();
|
||||||
}
|
}
|
||||||
goog.asserts.assert(features !== undefined, 'features should be defined');
|
goog.asserts.assert(features !== undefined, 'features should be defined');
|
||||||
@@ -328,12 +328,12 @@ ol.interaction.Snap.prototype.setMap = function(map) {
|
|||||||
goog.base(this, 'setMap', map);
|
goog.base(this, 'setMap', map);
|
||||||
|
|
||||||
if (map) {
|
if (map) {
|
||||||
if (!goog.isNull(this.features_)) {
|
if (this.features_) {
|
||||||
keys.push(this.features_.on(ol.CollectionEventType.ADD,
|
keys.push(this.features_.on(ol.CollectionEventType.ADD,
|
||||||
this.handleFeatureAdd_, this));
|
this.handleFeatureAdd_, this));
|
||||||
keys.push(this.features_.on(ol.CollectionEventType.REMOVE,
|
keys.push(this.features_.on(ol.CollectionEventType.REMOVE,
|
||||||
this.handleFeatureRemove_, this));
|
this.handleFeatureRemove_, this));
|
||||||
} else if (!goog.isNull(this.source_)) {
|
} else if (this.source_) {
|
||||||
keys.push(this.source_.on(ol.source.VectorEventType.ADDFEATURE,
|
keys.push(this.source_.on(ol.source.VectorEventType.ADDFEATURE,
|
||||||
this.handleFeatureAdd_, this));
|
this.handleFeatureAdd_, this));
|
||||||
keys.push(this.source_.on(ol.source.VectorEventType.REMOVEFEATURE,
|
keys.push(this.source_.on(ol.source.VectorEventType.REMOVEFEATURE,
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ goog.inherits(ol.interaction.Translate, ol.interaction.Pointer);
|
|||||||
*/
|
*/
|
||||||
ol.interaction.Translate.handleDownEvent_ = function(event) {
|
ol.interaction.Translate.handleDownEvent_ = function(event) {
|
||||||
this.lastFeature_ = this.featuresAtPixel_(event.pixel, event.map);
|
this.lastFeature_ = this.featuresAtPixel_(event.pixel, event.map);
|
||||||
if (goog.isNull(this.lastCoordinate_) && !goog.isNull(this.lastFeature_)) {
|
if (!this.lastCoordinate_ && this.lastFeature_) {
|
||||||
this.lastCoordinate_ = event.coordinate;
|
this.lastCoordinate_ = event.coordinate;
|
||||||
ol.interaction.Translate.handleMoveEvent_.call(this, event);
|
ol.interaction.Translate.handleMoveEvent_.call(this, event);
|
||||||
return true;
|
return true;
|
||||||
@@ -77,7 +77,7 @@ ol.interaction.Translate.handleDownEvent_ = function(event) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.interaction.Translate.handleUpEvent_ = function(event) {
|
ol.interaction.Translate.handleUpEvent_ = function(event) {
|
||||||
if (!goog.isNull(this.lastCoordinate_)) {
|
if (this.lastCoordinate_) {
|
||||||
this.lastCoordinate_ = null;
|
this.lastCoordinate_ = null;
|
||||||
ol.interaction.Translate.handleMoveEvent_.call(this, event);
|
ol.interaction.Translate.handleMoveEvent_.call(this, event);
|
||||||
return true;
|
return true;
|
||||||
@@ -92,18 +92,18 @@ ol.interaction.Translate.handleUpEvent_ = function(event) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.interaction.Translate.handleDragEvent_ = function(event) {
|
ol.interaction.Translate.handleDragEvent_ = function(event) {
|
||||||
if (!goog.isNull(this.lastCoordinate_)) {
|
if (this.lastCoordinate_) {
|
||||||
var newCoordinate = event.coordinate;
|
var newCoordinate = event.coordinate;
|
||||||
var deltaX = newCoordinate[0] - this.lastCoordinate_[0];
|
var deltaX = newCoordinate[0] - this.lastCoordinate_[0];
|
||||||
var deltaY = newCoordinate[1] - this.lastCoordinate_[1];
|
var deltaY = newCoordinate[1] - this.lastCoordinate_[1];
|
||||||
|
|
||||||
if (!goog.isNull(this.features_)) {
|
if (this.features_) {
|
||||||
this.features_.forEach(function(feature) {
|
this.features_.forEach(function(feature) {
|
||||||
var geom = feature.getGeometry();
|
var geom = feature.getGeometry();
|
||||||
geom.translate(deltaX, deltaY);
|
geom.translate(deltaX, deltaY);
|
||||||
feature.setGeometry(geom);
|
feature.setGeometry(geom);
|
||||||
});
|
});
|
||||||
} else if (goog.isNull(this.lastFeature_)) {
|
} else if (this.lastFeature_) {
|
||||||
var geom = this.lastFeature_.getGeometry();
|
var geom = this.lastFeature_.getGeometry();
|
||||||
geom.translate(deltaX, deltaY);
|
geom.translate(deltaX, deltaY);
|
||||||
this.lastFeature_.setGeometry(geom);
|
this.lastFeature_.setGeometry(geom);
|
||||||
@@ -130,7 +130,7 @@ ol.interaction.Translate.handleMoveEvent_ = function(event)
|
|||||||
if (intersectingFeature) {
|
if (intersectingFeature) {
|
||||||
var isSelected = false;
|
var isSelected = false;
|
||||||
|
|
||||||
if (!goog.isNull(this.features_) &&
|
if (this.features_ &&
|
||||||
ol.array.includes(this.features_.getArray(), intersectingFeature)) {
|
ol.array.includes(this.features_.getArray(), intersectingFeature)) {
|
||||||
isSelected = true;
|
isSelected = true;
|
||||||
}
|
}
|
||||||
@@ -138,12 +138,12 @@ ol.interaction.Translate.handleMoveEvent_ = function(event)
|
|||||||
this.previousCursor_ = elem.style.cursor;
|
this.previousCursor_ = elem.style.cursor;
|
||||||
|
|
||||||
// WebKit browsers don't support the grab icons without a prefix
|
// WebKit browsers don't support the grab icons without a prefix
|
||||||
elem.style.cursor = !goog.isNull(this.lastCoordinate_) ?
|
elem.style.cursor = this.lastCoordinate_ ?
|
||||||
'-webkit-grabbing' : (isSelected ? '-webkit-grab' : 'pointer');
|
'-webkit-grabbing' : (isSelected ? '-webkit-grab' : 'pointer');
|
||||||
|
|
||||||
// Thankfully, attempting to set the standard ones will silently fail,
|
// Thankfully, attempting to set the standard ones will silently fail,
|
||||||
// keeping the prefixed icons
|
// keeping the prefixed icons
|
||||||
elem.style.cursor = goog.isNull(this.lastCoordinate_) ?
|
elem.style.cursor = !this.lastCoordinate_ ?
|
||||||
'grabbing' : (isSelected ? 'grab' : 'pointer');
|
'grabbing' : (isSelected ? 'grab' : 'pointer');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -171,7 +171,7 @@ ol.interaction.Translate.prototype.featuresAtPixel_ = function(pixel, map) {
|
|||||||
return feature;
|
return feature;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!goog.isNull(this.features_) &&
|
if (this.features_ &&
|
||||||
ol.array.includes(this.features_.getArray(), intersectingFeature)) {
|
ol.array.includes(this.features_.getArray(), intersectingFeature)) {
|
||||||
found = intersectingFeature;
|
found = intersectingFeature;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user