Merge pull request #3461 from bjornharrtell/modifyevent
High level Modify interaction events
This commit is contained in:
@@ -49,6 +49,25 @@ oli.DrawEvent.prototype.feature;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
oli.ModifyEvent = function() {};
|
||||
|
||||
|
||||
/**
|
||||
* @type {ol.Collection.<ol.Feature>}
|
||||
*/
|
||||
oli.ModifyEvent.prototype.features;
|
||||
|
||||
|
||||
/**
|
||||
* @type {ol.MapBrowserPointerEvent}
|
||||
*/
|
||||
oli.ModifyEvent.prototype.mapBrowserPointerEvent;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,7 @@ goog.provide('ol.interaction.Modify');
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.events');
|
||||
goog.require('goog.events.Event');
|
||||
goog.require('goog.functions');
|
||||
goog.require('ol.Collection');
|
||||
goog.require('ol.CollectionEventType');
|
||||
@@ -26,6 +27,60 @@ goog.require('ol.structs.RBush');
|
||||
goog.require('ol.style.Style');
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
ol.ModifyEventType = {
|
||||
/**
|
||||
* Triggered upon feature modification start
|
||||
* @event ol.ModifyEvent#modifystart
|
||||
* @api
|
||||
*/
|
||||
MODIFYSTART: 'modifystart',
|
||||
/**
|
||||
* Triggered upon feature modification end
|
||||
* @event ol.ModifyEvent#modifyend
|
||||
* @api
|
||||
*/
|
||||
MODIFYEND: 'modifyend'
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Events emitted by {@link ol.interaction.Modify} instances are instances of
|
||||
* this type.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {goog.events.Event}
|
||||
* @implements {oli.ModifyEvent}
|
||||
* @param {ol.ModifyEventType} type Type.
|
||||
* @param {ol.Collection.<ol.Feature>} features The features modified.
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserPointerEvent Associated
|
||||
* {@link ol.MapBrowserPointerEvent}.
|
||||
*/
|
||||
ol.ModifyEvent = function(type, features, mapBrowserPointerEvent) {
|
||||
|
||||
goog.base(this, type);
|
||||
|
||||
/**
|
||||
* The features being modified.
|
||||
* @type {ol.Collection.<ol.Feature>}
|
||||
* @api
|
||||
*/
|
||||
this.features = features;
|
||||
|
||||
/**
|
||||
* Associated {@link ol.MapBrowserPointerEvent}.
|
||||
* @type {ol.MapBrowserPointerEvent}
|
||||
* @api
|
||||
*/
|
||||
this.mapBrowserPointerEvent = mapBrowserPointerEvent;
|
||||
};
|
||||
goog.inherits(ol.ModifyEvent, goog.events.Event);
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{depth: (Array.<number>|undefined),
|
||||
* feature: ol.Feature,
|
||||
@@ -44,7 +99,8 @@ ol.interaction.SegmentDataType;
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Pointer}
|
||||
* @param {olx.interaction.ModifyOptions} options Options.
|
||||
* @api stable
|
||||
* @fires ol.ModifyEvent
|
||||
* @api
|
||||
*/
|
||||
ol.interaction.Modify = function(options) {
|
||||
|
||||
@@ -466,6 +522,8 @@ ol.interaction.Modify.handleDownEvent_ = function(evt) {
|
||||
for (i = insertVertices.length - 1; i >= 0; --i) {
|
||||
this.insertVertex_.apply(this, insertVertices[i]);
|
||||
}
|
||||
this.dispatchEvent(new ol.ModifyEvent(ol.ModifyEventType.MODIFYSTART,
|
||||
this.features_, evt));
|
||||
}
|
||||
return !goog.isNull(this.vertexFeature_);
|
||||
};
|
||||
@@ -537,6 +595,8 @@ ol.interaction.Modify.handleUpEvent_ = function(evt) {
|
||||
this.rBush_.update(ol.extent.boundingExtent(segmentData.segment),
|
||||
segmentData);
|
||||
}
|
||||
this.dispatchEvent(new ol.ModifyEvent(ol.ModifyEventType.MODIFYEND,
|
||||
this.features_, evt));
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user