Add draw interaction events
This commit is contained in:
@@ -1 +1,4 @@
|
|||||||
@exportSymbol ol.interaction.Draw
|
@exportSymbol ol.interaction.Draw
|
||||||
|
|
||||||
|
@exportSymbol ol.DrawEvent
|
||||||
|
@exportProperty ol.DrawEvent.prototype.getFeature
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
goog.provide('ol.DrawEvent');
|
||||||
goog.provide('ol.interaction.Draw');
|
goog.provide('ol.interaction.Draw');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
goog.require('goog.asserts');
|
||||||
|
goog.require('goog.events.Event');
|
||||||
goog.require('ol.Collection');
|
goog.require('ol.Collection');
|
||||||
goog.require('ol.Coordinate');
|
goog.require('ol.Coordinate');
|
||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
@@ -23,6 +25,44 @@ goog.require('ol.style.Stroke');
|
|||||||
goog.require('ol.style.Style');
|
goog.require('ol.style.Style');
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
ol.DrawEventType = {
|
||||||
|
DRAWSTART: 'drawstart',
|
||||||
|
DRAWEND: 'drawend'
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends {goog.events.Event}
|
||||||
|
* @param {ol.DrawEventType} type Type.
|
||||||
|
* @param {ol.Feature} feature The feature drawn.
|
||||||
|
*/
|
||||||
|
ol.DrawEvent = function(type, feature) {
|
||||||
|
|
||||||
|
goog.base(this, type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {ol.Feature}
|
||||||
|
*/
|
||||||
|
this.feature_ = feature;
|
||||||
|
|
||||||
|
};
|
||||||
|
goog.inherits(ol.DrawEvent, goog.events.Event);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {ol.Feature} The feature drawn to which this event pertains.
|
||||||
|
*/
|
||||||
|
ol.DrawEvent.prototype.getFeature = function() {
|
||||||
|
return this.feature_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interaction that allows drawing geometries
|
* Interaction that allows drawing geometries
|
||||||
@@ -315,6 +355,8 @@ ol.interaction.Draw.prototype.startDrawing_ = function(event) {
|
|||||||
goog.asserts.assert(goog.isDef(geometry));
|
goog.asserts.assert(goog.isDef(geometry));
|
||||||
this.sketchFeature_ = new ol.Feature(geometry);
|
this.sketchFeature_ = new ol.Feature(geometry);
|
||||||
this.updateSketchFeatures_();
|
this.updateSketchFeatures_();
|
||||||
|
this.dispatchEvent(new ol.DrawEvent(ol.DrawEventType.DRAWSTART,
|
||||||
|
this.sketchFeature_));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -430,6 +472,8 @@ ol.interaction.Draw.prototype.finishDrawing_ = function(event) {
|
|||||||
goog.asserts.assertInstanceof(vectorSource, ol.source.Vector);
|
goog.asserts.assertInstanceof(vectorSource, ol.source.Vector);
|
||||||
vectorSource.addFeature(sketchFeature);
|
vectorSource.addFeature(sketchFeature);
|
||||||
}
|
}
|
||||||
|
this.dispatchEvent(new ol.DrawEvent(ol.DrawEventType.DRAWEND,
|
||||||
|
this.sketchFeature_));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user