Merge pull request #1517 from fredj/vector-api-drawinteraction-cleanup
[vector-api] drawinteraction cleanup
This commit is contained in:
@@ -16,6 +16,7 @@ goog.require('ol.geom.Point');
|
|||||||
goog.require('ol.geom.Polygon');
|
goog.require('ol.geom.Polygon');
|
||||||
goog.require('ol.interaction.Interaction');
|
goog.require('ol.interaction.Interaction');
|
||||||
goog.require('ol.render.FeaturesOverlay');
|
goog.require('ol.render.FeaturesOverlay');
|
||||||
|
goog.require('ol.source.Vector');
|
||||||
goog.require('ol.style.Circle');
|
goog.require('ol.style.Circle');
|
||||||
goog.require('ol.style.Fill');
|
goog.require('ol.style.Fill');
|
||||||
goog.require('ol.style.Stroke');
|
goog.require('ol.style.Stroke');
|
||||||
@@ -265,7 +266,7 @@ ol.interaction.Draw.prototype.handleMove_ = function(event) {
|
|||||||
*/
|
*/
|
||||||
ol.interaction.Draw.prototype.atFinish_ = function(event) {
|
ol.interaction.Draw.prototype.atFinish_ = function(event) {
|
||||||
var at = false;
|
var at = false;
|
||||||
if (this.sketchFeature_) {
|
if (!goog.isNull(this.sketchFeature_)) {
|
||||||
var geometry = this.sketchFeature_.getGeometry();
|
var geometry = this.sketchFeature_.getGeometry();
|
||||||
var potentiallyDone = false;
|
var potentiallyDone = false;
|
||||||
if (this.mode_ === ol.interaction.DrawMode.LINE_STRING) {
|
if (this.mode_ === ol.interaction.DrawMode.LINE_STRING) {
|
||||||
@@ -424,8 +425,10 @@ ol.interaction.Draw.prototype.finishDrawing_ = function(event) {
|
|||||||
sketchFeature.setGeometry(new ol.geom.MultiPolygon([coordinates]));
|
sketchFeature.setGeometry(new ol.geom.MultiPolygon([coordinates]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.layer_) {
|
if (!goog.isNull(this.layer_)) {
|
||||||
this.layer_.getSource().addFeature(sketchFeature);
|
var vectorSource = this.layer_.getSource();
|
||||||
|
goog.asserts.assertInstanceof(vectorSource, ol.source.Vector);
|
||||||
|
vectorSource.addFeature(sketchFeature);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -454,10 +457,10 @@ ol.interaction.Draw.prototype.abortDrawing_ = function() {
|
|||||||
*/
|
*/
|
||||||
ol.interaction.Draw.prototype.updateSketchFeatures_ = function() {
|
ol.interaction.Draw.prototype.updateSketchFeatures_ = function() {
|
||||||
var sketchFeatures = [this.sketchFeature_];
|
var sketchFeatures = [this.sketchFeature_];
|
||||||
if (this.sketchLine_) {
|
if (!goog.isNull(this.sketchLine_)) {
|
||||||
sketchFeatures.push(this.sketchLine_);
|
sketchFeatures.push(this.sketchLine_);
|
||||||
}
|
}
|
||||||
if (this.sketchPoint_) {
|
if (!goog.isNull(this.sketchPoint_)) {
|
||||||
sketchFeatures.push(this.sketchPoint_);
|
sketchFeatures.push(this.sketchPoint_);
|
||||||
}
|
}
|
||||||
this.overlay_.setFeatures(new ol.Collection(sketchFeatures));
|
this.overlay_.setFeatures(new ol.Collection(sketchFeatures));
|
||||||
|
|||||||
Reference in New Issue
Block a user