Merge pull request #5864 from fredj/more_renaming

More renaming
This commit is contained in:
Frédéric Junod
2016-09-08 13:03:11 +02:00
committed by GitHub
5 changed files with 210 additions and 211 deletions

View File

@@ -17,10 +17,16 @@ A number of internal types have been renamed. This will not affect those who us
* rename `ol.OverlayProperty` to `ol.Overlay.Property`
* rename `ol.control.MousePositionProperty` to `ol.control.MousePosition.Property`
* rename `ol.format.IGCZ` to `ol.format.IGC.Z`
* rename `ol.interaction.DrawMode` to `ol.interaction.Draw.Mode`
* rename `ol.interaction.DrawEvent` to `ol.interaction.Draw.Event`
* rename `ol.interaction.DrawEventType` to `ol.interaction.Draw.EventType`
* rename `ol.interaction.ExtentEvent` to `ol.interaction.Extent.Event`
* rename `ol.interaction.ExtentEventType` to `ol.interaction.Extent.EventType`
* rename `ol.interaction.DragAndDropEvent` to `ol.interaction.DragAndDrop.Event`
* rename `ol.interaction.DragAndDropEventType` to `ol.interaction.DragAndDrop.EventType`
* rename `ol.interaction.ModifyEvent` to `ol.interaction.Modify.Event`
* rename `ol.interaction.SelectEvent` to `ol.interaction.Select.Event`
* rename `ol.interaction.SelectEventType` to `ol.interaction.Select.EventType`
* rename `ol.interaction.TranslateEvent` to `ol.interaction.Translate.Event`
* rename `ol.interaction.TranslateEventType` to `ol.interaction.Translate.EventType`
* rename `ol.layer.GroupProperty` to `ol.layer.Group.Property`
@@ -29,6 +35,7 @@ A number of internal types have been renamed. This will not affect those who us
* rename `ol.layer.VectorTileRenderType` to `ol.layer.VectorTile.RenderType`
* rename `ol.MapEventType` to `ol.MapEvent.Type`
* rename `ol.MapProperty` to `ol.Map.Property`
* rename `ol.ModifyEventType` to `ol.interaction.Modify.EventType`
* rename `ol.RendererType` to `ol.renderer.Type`
* rename `ol.source.ImageEvent` to `ol.source.Image.Event`
* rename `ol.source.ImageEventType` to `ol.source.Image.EventType`

View File

@@ -1,7 +1,4 @@
goog.provide('ol.interaction.Draw');
goog.provide('ol.interaction.DrawEvent');
goog.provide('ol.interaction.DrawEventType');
goog.provide('ol.interaction.DrawMode');
goog.require('ol');
goog.require('ol.events');
@@ -27,58 +24,13 @@ goog.require('ol.source.Vector');
goog.require('ol.style.Style');
/**
* @enum {string}
*/
ol.interaction.DrawEventType = {
/**
* Triggered upon feature draw start
* @event ol.interaction.DrawEvent#drawstart
* @api stable
*/
DRAWSTART: 'drawstart',
/**
* Triggered upon feature draw end
* @event ol.interaction.DrawEvent#drawend
* @api stable
*/
DRAWEND: 'drawend'
};
/**
* @classdesc
* Events emitted by {@link ol.interaction.Draw} instances are instances of
* this type.
*
* @constructor
* @extends {ol.events.Event}
* @implements {oli.DrawEvent}
* @param {ol.interaction.DrawEventType} type Type.
* @param {ol.Feature} feature The feature drawn.
*/
ol.interaction.DrawEvent = function(type, feature) {
ol.events.Event.call(this, type);
/**
* The feature being drawn.
* @type {ol.Feature}
* @api stable
*/
this.feature = feature;
};
ol.inherits(ol.interaction.DrawEvent, ol.events.Event);
/**
* @classdesc
* Interaction for drawing feature geometries.
*
* @constructor
* @extends {ol.interaction.Pointer}
* @fires ol.interaction.DrawEvent
* @fires ol.interaction.Draw.Event
* @param {olx.interaction.DrawOptions} options Options.
* @api stable
*/
@@ -132,7 +84,7 @@ ol.interaction.Draw = function(options) {
/**
* Drawing mode (derived from geometry type.
* @type {ol.interaction.DrawMode}
* @type {ol.interaction.Draw.Mode}
* @private
*/
this.mode_ = ol.interaction.Draw.getMode_(this.type_);
@@ -146,7 +98,7 @@ ol.interaction.Draw = function(options) {
*/
this.minPoints_ = options.minPoints ?
options.minPoints :
(this.mode_ === ol.interaction.DrawMode.POLYGON ? 3 : 2);
(this.mode_ === ol.interaction.Draw.Mode.POLYGON ? 3 : 2);
/**
* The number of points that can be drawn before a polygon ring or line string
@@ -183,11 +135,11 @@ ol.interaction.Draw = function(options) {
} else {
var Constructor;
var mode = this.mode_;
if (mode === ol.interaction.DrawMode.POINT) {
if (mode === ol.interaction.Draw.Mode.POINT) {
Constructor = ol.geom.Point;
} else if (mode === ol.interaction.DrawMode.LINE_STRING) {
} else if (mode === ol.interaction.Draw.Mode.LINE_STRING) {
Constructor = ol.geom.LineString;
} else if (mode === ol.interaction.DrawMode.POLYGON) {
} else if (mode === ol.interaction.Draw.Mode.POLYGON) {
Constructor = ol.geom.Polygon;
}
/**
@@ -339,8 +291,8 @@ ol.interaction.Draw.prototype.setMap = function(map) {
* @api
*/
ol.interaction.Draw.handleEvent = function(mapBrowserEvent) {
if ((this.mode_ === ol.interaction.DrawMode.LINE_STRING ||
this.mode_ === ol.interaction.DrawMode.POLYGON) &&
if ((this.mode_ === ol.interaction.Draw.Mode.LINE_STRING ||
this.mode_ === ol.interaction.Draw.Mode.POLYGON) &&
this.freehandCondition_(mapBrowserEvent)) {
this.freehand_ = true;
}
@@ -399,10 +351,10 @@ ol.interaction.Draw.handleUpEvent_ = function(event) {
this.handlePointerMove_(event);
if (!this.finishCoordinate_) {
this.startDrawing_(event);
if (this.mode_ === ol.interaction.DrawMode.POINT) {
if (this.mode_ === ol.interaction.Draw.Mode.POINT) {
this.finishDrawing();
}
} else if (this.mode_ === ol.interaction.DrawMode.CIRCLE) {
} else if (this.mode_ === ol.interaction.Draw.Mode.CIRCLE) {
this.finishDrawing();
} else if (this.atFinish_(event)) {
if (this.finishCondition_(event)) {
@@ -444,9 +396,9 @@ ol.interaction.Draw.prototype.atFinish_ = function(event) {
if (this.sketchFeature_) {
var potentiallyDone = false;
var potentiallyFinishCoordinates = [this.finishCoordinate_];
if (this.mode_ === ol.interaction.DrawMode.LINE_STRING) {
if (this.mode_ === ol.interaction.Draw.Mode.LINE_STRING) {
potentiallyDone = this.sketchCoords_.length > this.minPoints_;
} else if (this.mode_ === ol.interaction.DrawMode.POLYGON) {
} else if (this.mode_ === ol.interaction.Draw.Mode.POLYGON) {
potentiallyDone = this.sketchCoords_[0].length >
this.minPoints_;
potentiallyFinishCoordinates = [this.sketchCoords_[0][0],
@@ -498,14 +450,14 @@ ol.interaction.Draw.prototype.createOrUpdateSketchPoint_ = function(event) {
ol.interaction.Draw.prototype.startDrawing_ = function(event) {
var start = event.coordinate;
this.finishCoordinate_ = start;
if (this.mode_ === ol.interaction.DrawMode.POINT) {
if (this.mode_ === ol.interaction.Draw.Mode.POINT) {
this.sketchCoords_ = start.slice();
} else if (this.mode_ === ol.interaction.DrawMode.POLYGON) {
} else if (this.mode_ === ol.interaction.Draw.Mode.POLYGON) {
this.sketchCoords_ = [[start.slice(), start.slice()]];
this.sketchLineCoords_ = this.sketchCoords_[0];
} else {
this.sketchCoords_ = [start.slice(), start.slice()];
if (this.mode_ === ol.interaction.DrawMode.CIRCLE) {
if (this.mode_ === ol.interaction.Draw.Mode.CIRCLE) {
this.sketchLineCoords_ = this.sketchCoords_;
}
}
@@ -521,8 +473,8 @@ ol.interaction.Draw.prototype.startDrawing_ = function(event) {
}
this.sketchFeature_.setGeometry(geometry);
this.updateSketchFeatures_();
this.dispatchEvent(new ol.interaction.DrawEvent(
ol.interaction.DrawEventType.DRAWSTART, this.sketchFeature_));
this.dispatchEvent(new ol.interaction.Draw.Event(
ol.interaction.Draw.EventType.DRAWSTART, this.sketchFeature_));
};
@@ -535,9 +487,9 @@ ol.interaction.Draw.prototype.modifyDrawing_ = function(event) {
var coordinate = event.coordinate;
var geometry = /** @type {ol.geom.SimpleGeometry} */ (this.sketchFeature_.getGeometry());
var coordinates, last;
if (this.mode_ === ol.interaction.DrawMode.POINT) {
if (this.mode_ === ol.interaction.Draw.Mode.POINT) {
last = this.sketchCoords_;
} else if (this.mode_ === ol.interaction.DrawMode.POLYGON) {
} else if (this.mode_ === ol.interaction.Draw.Mode.POLYGON) {
coordinates = this.sketchCoords_[0];
last = coordinates[coordinates.length - 1];
if (this.atFinish_(event)) {
@@ -560,7 +512,7 @@ ol.interaction.Draw.prototype.modifyDrawing_ = function(event) {
}
var sketchLineGeom;
if (geometry instanceof ol.geom.Polygon &&
this.mode_ !== ol.interaction.DrawMode.POLYGON) {
this.mode_ !== ol.interaction.Draw.Mode.POLYGON) {
if (!this.sketchLine_) {
this.sketchLine_ = new ol.Feature(new ol.geom.LineString(null));
}
@@ -586,13 +538,13 @@ ol.interaction.Draw.prototype.addToDrawing_ = function(event) {
var geometry = /** @type {ol.geom.SimpleGeometry} */ (this.sketchFeature_.getGeometry());
var done;
var coordinates;
if (this.mode_ === ol.interaction.DrawMode.LINE_STRING) {
if (this.mode_ === ol.interaction.Draw.Mode.LINE_STRING) {
this.finishCoordinate_ = coordinate.slice();
coordinates = this.sketchCoords_;
coordinates.push(coordinate.slice());
done = coordinates.length > this.maxPoints_;
this.geometryFunction_(coordinates, geometry);
} else if (this.mode_ === ol.interaction.DrawMode.POLYGON) {
} else if (this.mode_ === ol.interaction.Draw.Mode.POLYGON) {
coordinates = this.sketchCoords_[0];
coordinates.push(coordinate.slice());
done = coordinates.length > this.maxPoints_;
@@ -615,11 +567,11 @@ ol.interaction.Draw.prototype.addToDrawing_ = function(event) {
ol.interaction.Draw.prototype.removeLastPoint = function() {
var geometry = /** @type {ol.geom.SimpleGeometry} */ (this.sketchFeature_.getGeometry());
var coordinates, sketchLineGeom;
if (this.mode_ === ol.interaction.DrawMode.LINE_STRING) {
if (this.mode_ === ol.interaction.Draw.Mode.LINE_STRING) {
coordinates = this.sketchCoords_;
coordinates.splice(-2, 1);
this.geometryFunction_(coordinates, geometry);
} else if (this.mode_ === ol.interaction.DrawMode.POLYGON) {
} else if (this.mode_ === ol.interaction.Draw.Mode.POLYGON) {
coordinates = this.sketchCoords_[0];
coordinates.splice(-2, 1);
sketchLineGeom = /** @type {ol.geom.LineString} */ (this.sketchLine_.getGeometry());
@@ -637,7 +589,7 @@ ol.interaction.Draw.prototype.removeLastPoint = function() {
/**
* Stop drawing and add the sketch feature to the target layer.
* The {@link ol.interaction.DrawEventType.DRAWEND} event is dispatched before
* The {@link ol.interaction.Draw.EventType.DRAWEND} event is dispatched before
* inserting the feature.
* @api
*/
@@ -645,11 +597,11 @@ ol.interaction.Draw.prototype.finishDrawing = function() {
var sketchFeature = this.abortDrawing_();
var coordinates = this.sketchCoords_;
var geometry = /** @type {ol.geom.SimpleGeometry} */ (sketchFeature.getGeometry());
if (this.mode_ === ol.interaction.DrawMode.LINE_STRING) {
if (this.mode_ === ol.interaction.Draw.Mode.LINE_STRING) {
// remove the redundant last point
coordinates.pop();
this.geometryFunction_(coordinates, geometry);
} else if (this.mode_ === ol.interaction.DrawMode.POLYGON) {
} else if (this.mode_ === ol.interaction.Draw.Mode.POLYGON) {
// When we finish drawing a polygon on the last point,
// the last coordinate is duplicated as for LineString
// we force the replacement by the first point
@@ -668,8 +620,8 @@ ol.interaction.Draw.prototype.finishDrawing = function() {
}
// First dispatch event to allow full set up of feature
this.dispatchEvent(new ol.interaction.DrawEvent(
ol.interaction.DrawEventType.DRAWEND, sketchFeature));
this.dispatchEvent(new ol.interaction.Draw.Event(
ol.interaction.Draw.EventType.DRAWEND, sketchFeature));
// Then insert feature
if (this.features_) {
@@ -708,7 +660,7 @@ ol.interaction.Draw.prototype.abortDrawing_ = function() {
*/
ol.interaction.Draw.prototype.extend = function(feature) {
var geometry = feature.getGeometry();
ol.DEBUG && console.assert(this.mode_ == ol.interaction.DrawMode.LINE_STRING,
ol.DEBUG && console.assert(this.mode_ == ol.interaction.Draw.Mode.LINE_STRING,
'interaction mode must be "line"');
ol.DEBUG && console.assert(geometry.getType() == ol.geom.GeometryType.LINE_STRING,
'feature geometry must be a line string');
@@ -719,8 +671,8 @@ ol.interaction.Draw.prototype.extend = function(feature) {
this.finishCoordinate_ = last.slice();
this.sketchCoords_.push(last.slice());
this.updateSketchFeatures_();
this.dispatchEvent(new ol.interaction.DrawEvent(
ol.interaction.DrawEventType.DRAWSTART, this.sketchFeature_));
this.dispatchEvent(new ol.interaction.Draw.Event(
ol.interaction.Draw.EventType.DRAWSTART, this.sketchFeature_));
};
@@ -804,24 +756,24 @@ ol.interaction.Draw.createRegularPolygon = function(opt_sides, opt_angle) {
* Get the drawing mode. The mode for mult-part geometries is the same as for
* their single-part cousins.
* @param {ol.geom.GeometryType} type Geometry type.
* @return {ol.interaction.DrawMode} Drawing mode.
* @return {ol.interaction.Draw.Mode} Drawing mode.
* @private
*/
ol.interaction.Draw.getMode_ = function(type) {
var mode;
if (type === ol.geom.GeometryType.POINT ||
type === ol.geom.GeometryType.MULTI_POINT) {
mode = ol.interaction.DrawMode.POINT;
mode = ol.interaction.Draw.Mode.POINT;
} else if (type === ol.geom.GeometryType.LINE_STRING ||
type === ol.geom.GeometryType.MULTI_LINE_STRING) {
mode = ol.interaction.DrawMode.LINE_STRING;
mode = ol.interaction.Draw.Mode.LINE_STRING;
} else if (type === ol.geom.GeometryType.POLYGON ||
type === ol.geom.GeometryType.MULTI_POLYGON) {
mode = ol.interaction.DrawMode.POLYGON;
mode = ol.interaction.Draw.Mode.POLYGON;
} else if (type === ol.geom.GeometryType.CIRCLE) {
mode = ol.interaction.DrawMode.CIRCLE;
mode = ol.interaction.Draw.Mode.CIRCLE;
}
return /** @type {!ol.interaction.DrawMode} */ (mode);
return /** @type {!ol.interaction.Draw.Mode} */ (mode);
};
@@ -830,9 +782,53 @@ ol.interaction.Draw.getMode_ = function(type) {
* cousins.
* @enum {string}
*/
ol.interaction.DrawMode = {
ol.interaction.Draw.Mode = {
POINT: 'Point',
LINE_STRING: 'LineString',
POLYGON: 'Polygon',
CIRCLE: 'Circle'
};
/**
* @classdesc
* Events emitted by {@link ol.interaction.Draw} instances are instances of
* this type.
*
* @constructor
* @extends {ol.events.Event}
* @implements {oli.DrawEvent}
* @param {ol.interaction.Draw.EventType} type Type.
* @param {ol.Feature} feature The feature drawn.
*/
ol.interaction.Draw.Event = function(type, feature) {
ol.events.Event.call(this, type);
/**
* The feature being drawn.
* @type {ol.Feature}
* @api stable
*/
this.feature = feature;
};
ol.inherits(ol.interaction.Draw.Event, ol.events.Event);
/**
* @enum {string}
*/
ol.interaction.Draw.EventType = {
/**
* Triggered upon feature draw start
* @event ol.interaction.Draw.Event#drawstart
* @api stable
*/
DRAWSTART: 'drawstart',
/**
* Triggered upon feature draw end
* @event ol.interaction.Draw.Event#drawend
* @api stable
*/
DRAWEND: 'drawend'
};

View File

@@ -1,5 +1,4 @@
goog.provide('ol.interaction.Modify');
goog.provide('ol.interaction.ModifyEvent');
goog.require('ol');
goog.require('ol.Collection');
@@ -23,59 +22,6 @@ goog.require('ol.structs.RBush');
goog.require('ol.style.Style');
/**
* @enum {string}
*/
ol.ModifyEventType = {
/**
* Triggered upon feature modification start
* @event ol.interaction.ModifyEvent#modifystart
* @api
*/
MODIFYSTART: 'modifystart',
/**
* Triggered upon feature modification end
* @event ol.interaction.ModifyEvent#modifyend
* @api
*/
MODIFYEND: 'modifyend'
};
/**
* @classdesc
* Events emitted by {@link ol.interaction.Modify} instances are instances of
* this type.
*
* @constructor
* @extends {ol.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.interaction.ModifyEvent = function(type, features, mapBrowserPointerEvent) {
ol.events.Event.call(this, type);
/**
* The features being modified.
* @type {ol.Collection.<ol.Feature>}
* @api
*/
this.features = features;
/**
* Associated {@link ol.MapBrowserEvent}.
* @type {ol.MapBrowserEvent}
* @api
*/
this.mapBrowserEvent = mapBrowserPointerEvent;
};
ol.inherits(ol.interaction.ModifyEvent, ol.events.Event);
/**
* @classdesc
* Interaction for modifying feature geometries.
@@ -83,7 +29,7 @@ ol.inherits(ol.interaction.ModifyEvent, ol.events.Event);
* @constructor
* @extends {ol.interaction.Pointer}
* @param {olx.interaction.ModifyOptions} options Options.
* @fires ol.interaction.ModifyEvent
* @fires ol.interaction.Modify.Event
* @api
*/
ol.interaction.Modify = function(options) {
@@ -267,8 +213,8 @@ ol.interaction.Modify.prototype.addFeature_ = function(feature) {
ol.interaction.Modify.prototype.willModifyFeatures_ = function(evt) {
if (!this.modified_) {
this.modified_ = true;
this.dispatchEvent(new ol.interaction.ModifyEvent(
ol.ModifyEventType.MODIFYSTART, this.features_, evt));
this.dispatchEvent(new ol.interaction.Modify.Event(
ol.interaction.Modify.EventType.MODIFYSTART, this.features_, evt));
}
};
@@ -674,8 +620,8 @@ ol.interaction.Modify.handleUpEvent_ = function(evt) {
segmentData);
}
if (this.modified_) {
this.dispatchEvent(new ol.interaction.ModifyEvent(
ol.ModifyEventType.MODIFYEND, this.features_, evt));
this.dispatchEvent(new ol.interaction.Modify.Event(
ol.interaction.Modify.EventType.MODIFYEND, this.features_, evt));
this.modified_ = false;
}
return false;
@@ -872,8 +818,8 @@ ol.interaction.Modify.prototype.removePoint = function() {
var evt = this.lastPointerEvent_;
this.willModifyFeatures_(evt);
handled = this.removeVertex_();
this.dispatchEvent(new ol.interaction.ModifyEvent(
ol.ModifyEventType.MODIFYEND, this.features_, evt));
this.dispatchEvent(new ol.interaction.Modify.Event(
ol.interaction.Modify.EventType.MODIFYEND, this.features_, evt));
this.modified_ = false;
}
return handled;
@@ -1040,3 +986,56 @@ ol.interaction.Modify.getDefaultStyleFunction = function() {
return style[ol.geom.GeometryType.POINT];
};
};
/**
* @classdesc
* Events emitted by {@link ol.interaction.Modify} instances are instances of
* this type.
*
* @constructor
* @extends {ol.events.Event}
* @implements {oli.ModifyEvent}
* @param {ol.interaction.Modify.EventType} type Type.
* @param {ol.Collection.<ol.Feature>} features The features modified.
* @param {ol.MapBrowserPointerEvent} mapBrowserPointerEvent Associated
* {@link ol.MapBrowserPointerEvent}.
*/
ol.interaction.Modify.Event = function(type, features, mapBrowserPointerEvent) {
ol.events.Event.call(this, type);
/**
* The features being modified.
* @type {ol.Collection.<ol.Feature>}
* @api
*/
this.features = features;
/**
* Associated {@link ol.MapBrowserEvent}.
* @type {ol.MapBrowserEvent}
* @api
*/
this.mapBrowserEvent = mapBrowserPointerEvent;
};
ol.inherits(ol.interaction.Modify.Event, ol.events.Event);
/**
* @enum {string}
*/
ol.interaction.Modify.EventType = {
/**
* Triggered upon feature modification start
* @event ol.interaction.Modify.Event#modifystart
* @api
*/
MODIFYSTART: 'modifystart',
/**
* Triggered upon feature modification end
* @event ol.interaction.Modify.Event#modifyend
* @api
*/
MODIFYEND: 'modifyend'
};

View File

@@ -1,6 +1,4 @@
goog.provide('ol.interaction.Select');
goog.provide('ol.interaction.SelectEvent');
goog.provide('ol.interaction.SelectEventType');
goog.require('ol');
goog.require('ol.asserts');
@@ -19,60 +17,6 @@ goog.require('ol.source.Vector');
goog.require('ol.style.Style');
/**
* @enum {string}
*/
ol.interaction.SelectEventType = {
/**
* Triggered when feature(s) has been (de)selected.
* @event ol.interaction.SelectEvent#select
* @api
*/
SELECT: 'select'
};
/**
* @classdesc
* Events emitted by {@link ol.interaction.Select} instances are instances of
* this type.
*
* @param {string} type The event type.
* @param {Array.<ol.Feature>} selected Selected features.
* @param {Array.<ol.Feature>} deselected Deselected features.
* @param {ol.MapBrowserEvent} mapBrowserEvent Associated
* {@link ol.MapBrowserEvent}.
* @implements {oli.SelectEvent}
* @extends {ol.events.Event}
* @constructor
*/
ol.interaction.SelectEvent = function(type, selected, deselected, mapBrowserEvent) {
ol.events.Event.call(this, type);
/**
* Selected features array.
* @type {Array.<ol.Feature>}
* @api
*/
this.selected = selected;
/**
* Deselected features array.
* @type {Array.<ol.Feature>}
* @api
*/
this.deselected = deselected;
/**
* Associated {@link ol.MapBrowserEvent}.
* @type {ol.MapBrowserEvent}
* @api
*/
this.mapBrowserEvent = mapBrowserEvent;
};
ol.inherits(ol.interaction.SelectEvent, ol.events.Event);
/**
* @classdesc
* Interaction for selecting vector features. By default, selected features are
@@ -88,7 +32,7 @@ ol.inherits(ol.interaction.SelectEvent, ol.events.Event);
* @constructor
* @extends {ol.interaction.Interaction}
* @param {olx.interaction.SelectOptions=} opt_options Options.
* @fires ol.interaction.SelectEvent
* @fires ol.interaction.Select.Event
* @api stable
*/
ol.interaction.Select = function(opt_options) {
@@ -313,7 +257,7 @@ ol.interaction.Select.handleEvent = function(mapBrowserEvent) {
}
if (selected.length > 0 || deselected.length > 0) {
this.dispatchEvent(
new ol.interaction.SelectEvent(ol.interaction.SelectEventType.SELECT,
new ol.interaction.Select.Event(ol.interaction.Select.EventType.SELECT,
selected, deselected, mapBrowserEvent));
}
return ol.events.condition.pointerMove(mapBrowserEvent);
@@ -389,3 +333,57 @@ ol.interaction.Select.prototype.removeFeatureLayerAssociation_ = function(featur
var key = ol.getUid(feature);
delete this.featureLayerAssociation_[key];
};
/**
* @classdesc
* Events emitted by {@link ol.interaction.Select} instances are instances of
* this type.
*
* @param {ol.interaction.Select.EventType} type The event type.
* @param {Array.<ol.Feature>} selected Selected features.
* @param {Array.<ol.Feature>} deselected Deselected features.
* @param {ol.MapBrowserEvent} mapBrowserEvent Associated
* {@link ol.MapBrowserEvent}.
* @implements {oli.SelectEvent}
* @extends {ol.events.Event}
* @constructor
*/
ol.interaction.Select.Event = function(type, selected, deselected, mapBrowserEvent) {
ol.events.Event.call(this, type);
/**
* Selected features array.
* @type {Array.<ol.Feature>}
* @api
*/
this.selected = selected;
/**
* Deselected features array.
* @type {Array.<ol.Feature>}
* @api
*/
this.deselected = deselected;
/**
* Associated {@link ol.MapBrowserEvent}.
* @type {ol.MapBrowserEvent}
* @api
*/
this.mapBrowserEvent = mapBrowserEvent;
};
ol.inherits(ol.interaction.Select.Event, ol.events.Event);
/**
* @enum {string}
*/
ol.interaction.Select.EventType = {
/**
* Triggered when feature(s) has been (de)selected.
* @event ol.interaction.Select.Event#select
* @api
*/
SELECT: 'select'
};

View File

@@ -11,7 +11,6 @@ goog.require('ol.geom.LineString');
goog.require('ol.geom.Point');
goog.require('ol.geom.Polygon');
goog.require('ol.interaction.Modify');
goog.require('ol.interaction.ModifyEvent');
goog.require('ol.layer.Vector');
goog.require('ol.pointer.PointerEvent');
goog.require('ol.source.Vector');
@@ -102,7 +101,7 @@ describe('ol.interaction.Modify', function() {
* modifications. Helper function to
* @param {ol.Feature} feature Modified feature.
* @param {ol.interaction.Modify} interaction The interaction.
* @return {Array<ol.interaction.ModifyEvent|string>} events
* @return {Array<ol.interaction.Modify.Event|string>} events
*/
function trackEvents(feature, interaction) {
var events = [];
@@ -122,7 +121,7 @@ describe('ol.interaction.Modify', function() {
* Validates the event array to verify proper event sequence. Checks
* that first and last event are correct ModifyEvents and that feature
* modifications event are in between.
* @param {Array<ol.interaction.ModifyEvent|string>} events The events.
* @param {Array<ol.interaction.Modify.Event|string>} events The events.
* @param {Array<ol.Feature>} features The features.
*/
function validateEvents(events, features) {
@@ -131,11 +130,11 @@ describe('ol.interaction.Modify', function() {
var endevent = events[events.length - 1];
// first event should be modifystary
expect(startevent).to.be.an(ol.interaction.ModifyEvent);
expect(startevent).to.be.an(ol.interaction.Modify.Event);
expect(startevent.type).to.eql('modifystart');
// last event should be modifyend
expect(endevent).to.be.an(ol.interaction.ModifyEvent);
expect(endevent).to.be.an(ol.interaction.Modify.Event);
expect(endevent.type).to.eql('modifyend');
// make sure we get change events to events array