Include originating MapBrowserEvent in ol.DragBoxEvent

This commit is contained in:
Frederic Junod
2016-01-04 13:29:11 +01:00
parent 65b90df4b8
commit 7a364e0593
2 changed files with 17 additions and 3 deletions
+6
View File
@@ -35,6 +35,12 @@ oli.DragBoxEvent = function() {};
oli.DragBoxEvent.prototype.coordinate; oli.DragBoxEvent.prototype.coordinate;
/**
* @type {ol.MapBrowserEvent}
*/
oli.DragBoxEvent.prototype.mapBrowserEvent;
/** /**
* @interface * @interface
+11 -3
View File
@@ -46,11 +46,12 @@ ol.DragBoxEventType = {
* *
* @param {string} type The event type. * @param {string} type The event type.
* @param {ol.Coordinate} coordinate The event coordinate. * @param {ol.Coordinate} coordinate The event coordinate.
* @param {ol.MapBrowserEvent} mapBrowserEvent Originating event.
* @extends {goog.events.Event} * @extends {goog.events.Event}
* @constructor * @constructor
* @implements {oli.DragBoxEvent} * @implements {oli.DragBoxEvent}
*/ */
ol.DragBoxEvent = function(type, coordinate) { ol.DragBoxEvent = function(type, coordinate, mapBrowserEvent) {
goog.base(this, type); goog.base(this, type);
/** /**
@@ -61,6 +62,13 @@ ol.DragBoxEvent = function(type, coordinate) {
*/ */
this.coordinate = coordinate; this.coordinate = coordinate;
/**
* @const
* @type {ol.MapBrowserEvent}
* @api
*/
this.mapBrowserEvent = mapBrowserEvent;
}; };
goog.inherits(ol.DragBoxEvent, goog.events.Event); goog.inherits(ol.DragBoxEvent, goog.events.Event);
@@ -169,7 +177,7 @@ ol.interaction.DragBox.handleUpEvent_ = function(mapBrowserEvent) {
ol.DRAG_BOX_HYSTERESIS_PIXELS_SQUARED) { ol.DRAG_BOX_HYSTERESIS_PIXELS_SQUARED) {
this.onBoxEnd(mapBrowserEvent); this.onBoxEnd(mapBrowserEvent);
this.dispatchEvent(new ol.DragBoxEvent(ol.DragBoxEventType.BOXEND, this.dispatchEvent(new ol.DragBoxEvent(ol.DragBoxEventType.BOXEND,
mapBrowserEvent.coordinate)); mapBrowserEvent.coordinate, mapBrowserEvent));
} }
return false; return false;
}; };
@@ -192,7 +200,7 @@ ol.interaction.DragBox.handleDownEvent_ = function(mapBrowserEvent) {
this.box_.setMap(mapBrowserEvent.map); this.box_.setMap(mapBrowserEvent.map);
this.box_.setPixels(this.startPixel_, this.startPixel_); this.box_.setPixels(this.startPixel_, this.startPixel_);
this.dispatchEvent(new ol.DragBoxEvent(ol.DragBoxEventType.BOXSTART, this.dispatchEvent(new ol.DragBoxEvent(ol.DragBoxEventType.BOXSTART,
mapBrowserEvent.coordinate)); mapBrowserEvent.coordinate, mapBrowserEvent));
return true; return true;
} else { } else {
return false; return false;