Single provide from ol/collection.js
This commit is contained in:
@@ -12,6 +12,13 @@ This option was previously needed to use named colors with the WebGL renderer bu
|
|||||||
|
|
||||||
The URL constructor is supported by all modern browsers, but not by older ones, such as IE. To use the KML format in such older browsers, a URL polyfill will have to be loaded before use.
|
The URL constructor is supported by all modern browsers, but not by older ones, such as IE. To use the KML format in such older browsers, a URL polyfill will have to be loaded before use.
|
||||||
|
|
||||||
|
#### Changes only relevant to those who compile their applications together with the Closure Compiler
|
||||||
|
|
||||||
|
A number of internal types have been renamed. This will not affect those who use the API provided by the library, but if you are compiling your application together with OpenLayers and using type names, you'll need to do the following:
|
||||||
|
|
||||||
|
* rename `ol.CollectionEvent` to `ol.Collection.Event`
|
||||||
|
* rename `ol.CollectionEventType` to `ol.Collection.EventType`
|
||||||
|
|
||||||
### v3.17.0
|
### v3.17.0
|
||||||
|
|
||||||
#### `ol.source.MapQuest` removal
|
#### `ol.source.MapQuest` removal
|
||||||
|
|||||||
@@ -52,13 +52,13 @@ oli.events.Event.prototype.stopPropagation = function() {};
|
|||||||
/**
|
/**
|
||||||
* @interface
|
* @interface
|
||||||
*/
|
*/
|
||||||
oli.CollectionEvent = function() {};
|
oli.Collection.Event = function() {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {*}
|
* @type {*}
|
||||||
*/
|
*/
|
||||||
oli.CollectionEvent.prototype.element;
|
oli.Collection.Event.prototype.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -4,58 +4,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
goog.provide('ol.Collection');
|
goog.provide('ol.Collection');
|
||||||
goog.provide('ol.CollectionEvent');
|
|
||||||
goog.provide('ol.CollectionEventType');
|
|
||||||
|
|
||||||
goog.require('ol.events.Event');
|
goog.require('ol.events.Event');
|
||||||
goog.require('ol.Object');
|
goog.require('ol.Object');
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
ol.CollectionEventType = {
|
|
||||||
/**
|
|
||||||
* Triggered when an item is added to the collection.
|
|
||||||
* @event ol.CollectionEvent#add
|
|
||||||
* @api stable
|
|
||||||
*/
|
|
||||||
ADD: 'add',
|
|
||||||
/**
|
|
||||||
* Triggered when an item is removed from the collection.
|
|
||||||
* @event ol.CollectionEvent#remove
|
|
||||||
* @api stable
|
|
||||||
*/
|
|
||||||
REMOVE: 'remove'
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @classdesc
|
|
||||||
* Events emitted by {@link ol.Collection} instances are instances of this
|
|
||||||
* type.
|
|
||||||
*
|
|
||||||
* @constructor
|
|
||||||
* @extends {ol.events.Event}
|
|
||||||
* @implements {oli.CollectionEvent}
|
|
||||||
* @param {ol.CollectionEventType} type Type.
|
|
||||||
* @param {*=} opt_element Element.
|
|
||||||
*/
|
|
||||||
ol.CollectionEvent = function(type, opt_element) {
|
|
||||||
|
|
||||||
ol.events.Event.call(this, type);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The element that is added to or removed from the collection.
|
|
||||||
* @type {*}
|
|
||||||
* @api stable
|
|
||||||
*/
|
|
||||||
this.element = opt_element;
|
|
||||||
|
|
||||||
};
|
|
||||||
ol.inherits(ol.CollectionEvent, ol.events.Event);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
@@ -74,7 +27,7 @@ ol.CollectionProperty = {
|
|||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.Object}
|
* @extends {ol.Object}
|
||||||
* @fires ol.CollectionEvent
|
* @fires ol.Collection.Event
|
||||||
* @param {!Array.<T>=} opt_array Array.
|
* @param {!Array.<T>=} opt_array Array.
|
||||||
* @template T
|
* @template T
|
||||||
* @api stable
|
* @api stable
|
||||||
@@ -181,7 +134,7 @@ ol.Collection.prototype.insertAt = function(index, elem) {
|
|||||||
this.array_.splice(index, 0, elem);
|
this.array_.splice(index, 0, elem);
|
||||||
this.updateLength_();
|
this.updateLength_();
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new ol.CollectionEvent(ol.CollectionEventType.ADD, elem));
|
new ol.Collection.Event(ol.Collection.EventType.ADD, elem));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -239,7 +192,7 @@ ol.Collection.prototype.removeAt = function(index) {
|
|||||||
this.array_.splice(index, 1);
|
this.array_.splice(index, 1);
|
||||||
this.updateLength_();
|
this.updateLength_();
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new ol.CollectionEvent(ol.CollectionEventType.REMOVE, prev));
|
new ol.Collection.Event(ol.Collection.EventType.REMOVE, prev));
|
||||||
return prev;
|
return prev;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -256,9 +209,9 @@ ol.Collection.prototype.setAt = function(index, elem) {
|
|||||||
var prev = this.array_[index];
|
var prev = this.array_[index];
|
||||||
this.array_[index] = elem;
|
this.array_[index] = elem;
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new ol.CollectionEvent(ol.CollectionEventType.REMOVE, prev));
|
new ol.Collection.Event(ol.Collection.EventType.REMOVE, prev));
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new ol.CollectionEvent(ol.CollectionEventType.ADD, elem));
|
new ol.Collection.Event(ol.Collection.EventType.ADD, elem));
|
||||||
} else {
|
} else {
|
||||||
var j;
|
var j;
|
||||||
for (j = n; j < index; ++j) {
|
for (j = n; j < index; ++j) {
|
||||||
@@ -275,3 +228,48 @@ ol.Collection.prototype.setAt = function(index, elem) {
|
|||||||
ol.Collection.prototype.updateLength_ = function() {
|
ol.Collection.prototype.updateLength_ = function() {
|
||||||
this.set(ol.CollectionProperty.LENGTH, this.array_.length);
|
this.set(ol.CollectionProperty.LENGTH, this.array_.length);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
ol.Collection.EventType = {
|
||||||
|
/**
|
||||||
|
* Triggered when an item is added to the collection.
|
||||||
|
* @event ol.Collection.Event#add
|
||||||
|
* @api stable
|
||||||
|
*/
|
||||||
|
ADD: 'add',
|
||||||
|
/**
|
||||||
|
* Triggered when an item is removed from the collection.
|
||||||
|
* @event ol.Collection.Event#remove
|
||||||
|
* @api stable
|
||||||
|
*/
|
||||||
|
REMOVE: 'remove'
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @classdesc
|
||||||
|
* Events emitted by {@link ol.Collection} instances are instances of this
|
||||||
|
* type.
|
||||||
|
*
|
||||||
|
* @constructor
|
||||||
|
* @extends {ol.events.Event}
|
||||||
|
* @implements {oli.Collection.Event}
|
||||||
|
* @param {ol.Collection.EventType} type Type.
|
||||||
|
* @param {*=} opt_element Element.
|
||||||
|
*/
|
||||||
|
ol.Collection.Event = function(type, opt_element) {
|
||||||
|
|
||||||
|
ol.events.Event.call(this, type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The element that is added to or removed from the collection.
|
||||||
|
* @type {*}
|
||||||
|
* @api stable
|
||||||
|
*/
|
||||||
|
this.element = opt_element;
|
||||||
|
|
||||||
|
};
|
||||||
|
ol.inherits(ol.Collection.Event, ol.events.Event);
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ goog.require('ol.events.Event');
|
|||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.Collection');
|
goog.require('ol.Collection');
|
||||||
goog.require('ol.CollectionEventType');
|
|
||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
goog.require('ol.MapBrowserEvent.EventType');
|
goog.require('ol.MapBrowserEvent.EventType');
|
||||||
goog.require('ol.MapBrowserPointerEvent');
|
goog.require('ol.MapBrowserPointerEvent');
|
||||||
@@ -232,9 +231,9 @@ ol.interaction.Modify = function(options) {
|
|||||||
this.features_ = options.features;
|
this.features_ = options.features;
|
||||||
|
|
||||||
this.features_.forEach(this.addFeature_, this);
|
this.features_.forEach(this.addFeature_, this);
|
||||||
ol.events.listen(this.features_, ol.CollectionEventType.ADD,
|
ol.events.listen(this.features_, ol.Collection.EventType.ADD,
|
||||||
this.handleFeatureAdd_, this);
|
this.handleFeatureAdd_, this);
|
||||||
ol.events.listen(this.features_, ol.CollectionEventType.REMOVE,
|
ol.events.listen(this.features_, ol.Collection.EventType.REMOVE,
|
||||||
this.handleFeatureRemove_, this);
|
this.handleFeatureRemove_, this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -327,7 +326,7 @@ ol.interaction.Modify.prototype.setMap = function(map) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.CollectionEvent} evt Event.
|
* @param {ol.Collection.Event} evt Event.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.interaction.Modify.prototype.handleFeatureAdd_ = function(evt) {
|
ol.interaction.Modify.prototype.handleFeatureAdd_ = function(evt) {
|
||||||
@@ -349,7 +348,7 @@ ol.interaction.Modify.prototype.handleFeatureChange_ = function(evt) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.CollectionEvent} evt Event.
|
* @param {ol.Collection.Event} evt Event.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.interaction.Modify.prototype.handleFeatureRemove_ = function(evt) {
|
ol.interaction.Modify.prototype.handleFeatureRemove_ = function(evt) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ goog.provide('ol.interaction.SelectEvent');
|
|||||||
goog.provide('ol.interaction.SelectEventType');
|
goog.provide('ol.interaction.SelectEventType');
|
||||||
|
|
||||||
goog.require('ol.functions');
|
goog.require('ol.functions');
|
||||||
goog.require('ol.CollectionEventType');
|
goog.require('ol.Collection');
|
||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
goog.require('ol.array');
|
goog.require('ol.array');
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
@@ -185,9 +185,9 @@ ol.interaction.Select = function(opt_options) {
|
|||||||
this.featureLayerAssociation_ = {};
|
this.featureLayerAssociation_ = {};
|
||||||
|
|
||||||
var features = this.featureOverlay_.getSource().getFeaturesCollection();
|
var features = this.featureOverlay_.getSource().getFeaturesCollection();
|
||||||
ol.events.listen(features, ol.CollectionEventType.ADD,
|
ol.events.listen(features, ol.Collection.EventType.ADD,
|
||||||
this.addFeature_, this);
|
this.addFeature_, this);
|
||||||
ol.events.listen(features, ol.CollectionEventType.REMOVE,
|
ol.events.listen(features, ol.Collection.EventType.REMOVE,
|
||||||
this.removeFeature_, this);
|
this.removeFeature_, this);
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -355,7 +355,7 @@ ol.interaction.Select.getDefaultStyleFunction = function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.CollectionEvent} evt Event.
|
* @param {ol.Collection.Event} evt Event.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.interaction.Select.prototype.addFeature_ = function(evt) {
|
ol.interaction.Select.prototype.addFeature_ = function(evt) {
|
||||||
@@ -367,7 +367,7 @@ ol.interaction.Select.prototype.addFeature_ = function(evt) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.CollectionEvent} evt Event.
|
* @param {ol.Collection.Event} evt Event.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.interaction.Select.prototype.removeFeature_ = function(evt) {
|
ol.interaction.Select.prototype.removeFeature_ = function(evt) {
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ goog.provide('ol.interaction.SnapProperty');
|
|||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.Collection');
|
goog.require('ol.Collection');
|
||||||
goog.require('ol.CollectionEvent');
|
|
||||||
goog.require('ol.CollectionEventType');
|
|
||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
goog.require('ol.Object');
|
goog.require('ol.Object');
|
||||||
goog.require('ol.Observable');
|
goog.require('ol.Observable');
|
||||||
@@ -232,14 +230,14 @@ ol.interaction.Snap.prototype.getFeatures_ = function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.source.VectorEvent|ol.CollectionEvent} evt Event.
|
* @param {ol.source.VectorEvent|ol.Collection.Event} evt Event.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.interaction.Snap.prototype.handleFeatureAdd_ = function(evt) {
|
ol.interaction.Snap.prototype.handleFeatureAdd_ = function(evt) {
|
||||||
var feature;
|
var feature;
|
||||||
if (evt instanceof ol.source.VectorEvent) {
|
if (evt instanceof ol.source.VectorEvent) {
|
||||||
feature = evt.feature;
|
feature = evt.feature;
|
||||||
} else if (evt instanceof ol.CollectionEvent) {
|
} else if (evt instanceof ol.Collection.Event) {
|
||||||
feature = evt.element;
|
feature = evt.element;
|
||||||
}
|
}
|
||||||
this.addFeature(/** @type {ol.Feature} */ (feature));
|
this.addFeature(/** @type {ol.Feature} */ (feature));
|
||||||
@@ -247,14 +245,14 @@ ol.interaction.Snap.prototype.handleFeatureAdd_ = function(evt) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.source.VectorEvent|ol.CollectionEvent} evt Event.
|
* @param {ol.source.VectorEvent|ol.Collection.Event} evt Event.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.interaction.Snap.prototype.handleFeatureRemove_ = function(evt) {
|
ol.interaction.Snap.prototype.handleFeatureRemove_ = function(evt) {
|
||||||
var feature;
|
var feature;
|
||||||
if (evt instanceof ol.source.VectorEvent) {
|
if (evt instanceof ol.source.VectorEvent) {
|
||||||
feature = evt.feature;
|
feature = evt.feature;
|
||||||
} else if (evt instanceof ol.CollectionEvent) {
|
} else if (evt instanceof ol.Collection.Event) {
|
||||||
feature = evt.element;
|
feature = evt.element;
|
||||||
}
|
}
|
||||||
this.removeFeature(/** @type {ol.Feature} */ (feature));
|
this.removeFeature(/** @type {ol.Feature} */ (feature));
|
||||||
@@ -342,9 +340,9 @@ ol.interaction.Snap.prototype.setMap = function(map) {
|
|||||||
if (map) {
|
if (map) {
|
||||||
if (this.features_) {
|
if (this.features_) {
|
||||||
keys.push(
|
keys.push(
|
||||||
ol.events.listen(this.features_, ol.CollectionEventType.ADD,
|
ol.events.listen(this.features_, ol.Collection.EventType.ADD,
|
||||||
this.handleFeatureAdd_, this),
|
this.handleFeatureAdd_, this),
|
||||||
ol.events.listen(this.features_, ol.CollectionEventType.REMOVE,
|
ol.events.listen(this.features_, ol.Collection.EventType.REMOVE,
|
||||||
this.handleFeatureRemove_, this)
|
this.handleFeatureRemove_, this)
|
||||||
);
|
);
|
||||||
} else if (this.source_) {
|
} else if (this.source_) {
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
goog.provide('ol.layer.Group');
|
goog.provide('ol.layer.Group');
|
||||||
|
|
||||||
goog.require('ol.Collection');
|
goog.require('ol.Collection');
|
||||||
goog.require('ol.CollectionEvent');
|
|
||||||
goog.require('ol.CollectionEventType');
|
|
||||||
goog.require('ol.Object');
|
goog.require('ol.Object');
|
||||||
goog.require('ol.ObjectEventType');
|
goog.require('ol.ObjectEventType');
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
@@ -97,9 +95,9 @@ ol.layer.Group.prototype.handleLayersChanged_ = function(event) {
|
|||||||
|
|
||||||
var layers = this.getLayers();
|
var layers = this.getLayers();
|
||||||
this.layersListenerKeys_.push(
|
this.layersListenerKeys_.push(
|
||||||
ol.events.listen(layers, ol.CollectionEventType.ADD,
|
ol.events.listen(layers, ol.Collection.EventType.ADD,
|
||||||
this.handleLayersAdd_, this),
|
this.handleLayersAdd_, this),
|
||||||
ol.events.listen(layers, ol.CollectionEventType.REMOVE,
|
ol.events.listen(layers, ol.Collection.EventType.REMOVE,
|
||||||
this.handleLayersRemove_, this));
|
this.handleLayersRemove_, this));
|
||||||
|
|
||||||
for (var id in this.listenerKeys_) {
|
for (var id in this.listenerKeys_) {
|
||||||
@@ -124,7 +122,7 @@ ol.layer.Group.prototype.handleLayersChanged_ = function(event) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.CollectionEvent} collectionEvent Collection event.
|
* @param {ol.Collection.Event} collectionEvent Collection event.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.layer.Group.prototype.handleLayersAdd_ = function(collectionEvent) {
|
ol.layer.Group.prototype.handleLayersAdd_ = function(collectionEvent) {
|
||||||
@@ -143,7 +141,7 @@ ol.layer.Group.prototype.handleLayersAdd_ = function(collectionEvent) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.CollectionEvent} collectionEvent Collection event.
|
* @param {ol.Collection.Event} collectionEvent Collection event.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.layer.Group.prototype.handleLayersRemove_ = function(collectionEvent) {
|
ol.layer.Group.prototype.handleLayersRemove_ = function(collectionEvent) {
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ goog.provide('ol.MapProperty');
|
|||||||
|
|
||||||
goog.require('goog.async.nextTick');
|
goog.require('goog.async.nextTick');
|
||||||
goog.require('ol.Collection');
|
goog.require('ol.Collection');
|
||||||
goog.require('ol.CollectionEventType');
|
|
||||||
goog.require('ol.MapBrowserEvent');
|
goog.require('ol.MapBrowserEvent');
|
||||||
goog.require('ol.MapBrowserEvent.EventType');
|
goog.require('ol.MapBrowserEvent.EventType');
|
||||||
goog.require('ol.MapBrowserEventHandler');
|
goog.require('ol.MapBrowserEventHandler');
|
||||||
@@ -404,17 +403,17 @@ ol.Map = function(options) {
|
|||||||
control.setMap(this);
|
control.setMap(this);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
ol.events.listen(this.controls_, ol.CollectionEventType.ADD,
|
ol.events.listen(this.controls_, ol.Collection.EventType.ADD,
|
||||||
/**
|
/**
|
||||||
* @param {ol.CollectionEvent} event Collection event.
|
* @param {ol.Collection.Event} event Collection event.
|
||||||
*/
|
*/
|
||||||
function(event) {
|
function(event) {
|
||||||
event.element.setMap(this);
|
event.element.setMap(this);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
ol.events.listen(this.controls_, ol.CollectionEventType.REMOVE,
|
ol.events.listen(this.controls_, ol.Collection.EventType.REMOVE,
|
||||||
/**
|
/**
|
||||||
* @param {ol.CollectionEvent} event Collection event.
|
* @param {ol.Collection.Event} event Collection event.
|
||||||
*/
|
*/
|
||||||
function(event) {
|
function(event) {
|
||||||
event.element.setMap(null);
|
event.element.setMap(null);
|
||||||
@@ -429,17 +428,17 @@ ol.Map = function(options) {
|
|||||||
interaction.setMap(this);
|
interaction.setMap(this);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
ol.events.listen(this.interactions_, ol.CollectionEventType.ADD,
|
ol.events.listen(this.interactions_, ol.Collection.EventType.ADD,
|
||||||
/**
|
/**
|
||||||
* @param {ol.CollectionEvent} event Collection event.
|
* @param {ol.Collection.Event} event Collection event.
|
||||||
*/
|
*/
|
||||||
function(event) {
|
function(event) {
|
||||||
event.element.setMap(this);
|
event.element.setMap(this);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
ol.events.listen(this.interactions_, ol.CollectionEventType.REMOVE,
|
ol.events.listen(this.interactions_, ol.Collection.EventType.REMOVE,
|
||||||
/**
|
/**
|
||||||
* @param {ol.CollectionEvent} event Collection event.
|
* @param {ol.Collection.Event} event Collection event.
|
||||||
*/
|
*/
|
||||||
function(event) {
|
function(event) {
|
||||||
event.element.setMap(null);
|
event.element.setMap(null);
|
||||||
@@ -447,17 +446,17 @@ ol.Map = function(options) {
|
|||||||
|
|
||||||
this.overlays_.forEach(this.addOverlayInternal_, this);
|
this.overlays_.forEach(this.addOverlayInternal_, this);
|
||||||
|
|
||||||
ol.events.listen(this.overlays_, ol.CollectionEventType.ADD,
|
ol.events.listen(this.overlays_, ol.Collection.EventType.ADD,
|
||||||
/**
|
/**
|
||||||
* @param {ol.CollectionEvent} event Collection event.
|
* @param {ol.Collection.Event} event Collection event.
|
||||||
*/
|
*/
|
||||||
function(event) {
|
function(event) {
|
||||||
this.addOverlayInternal_(/** @type {ol.Overlay} */ (event.element));
|
this.addOverlayInternal_(/** @type {ol.Overlay} */ (event.element));
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
ol.events.listen(this.overlays_, ol.CollectionEventType.REMOVE,
|
ol.events.listen(this.overlays_, ol.Collection.EventType.REMOVE,
|
||||||
/**
|
/**
|
||||||
* @param {ol.CollectionEvent} event Collection event.
|
* @param {ol.Collection.Event} event Collection event.
|
||||||
*/
|
*/
|
||||||
function(event) {
|
function(event) {
|
||||||
var id = event.element.getId();
|
var id = event.element.getId();
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ goog.provide('ol.source.VectorEventType');
|
|||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.Collection');
|
goog.require('ol.Collection');
|
||||||
goog.require('ol.CollectionEventType');
|
|
||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
goog.require('ol.ObjectEventType');
|
goog.require('ol.ObjectEventType');
|
||||||
goog.require('ol.array');
|
goog.require('ol.array');
|
||||||
@@ -348,7 +347,7 @@ ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) {
|
|||||||
modifyingCollection = false;
|
modifyingCollection = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ol.events.listen(collection, ol.CollectionEventType.ADD,
|
ol.events.listen(collection, ol.Collection.EventType.ADD,
|
||||||
function(evt) {
|
function(evt) {
|
||||||
if (!modifyingCollection) {
|
if (!modifyingCollection) {
|
||||||
modifyingCollection = true;
|
modifyingCollection = true;
|
||||||
@@ -356,7 +355,7 @@ ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) {
|
|||||||
modifyingCollection = false;
|
modifyingCollection = false;
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
ol.events.listen(collection, ol.CollectionEventType.REMOVE,
|
ol.events.listen(collection, ol.Collection.EventType.REMOVE,
|
||||||
function(evt) {
|
function(evt) {
|
||||||
if (!modifyingCollection) {
|
if (!modifyingCollection) {
|
||||||
modifyingCollection = true;
|
modifyingCollection = true;
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ describe('ol.collection', function() {
|
|||||||
it('fires a remove event', function() {
|
it('fires a remove event', function() {
|
||||||
var collection = new ol.Collection([0, 1, 2]);
|
var collection = new ol.Collection([0, 1, 2]);
|
||||||
var cb = sinon.spy();
|
var cb = sinon.spy();
|
||||||
ol.events.listen(collection, ol.CollectionEventType.REMOVE, cb);
|
ol.events.listen(collection, ol.Collection.EventType.REMOVE, cb);
|
||||||
expect(collection.remove(1)).to.eql(1);
|
expect(collection.remove(1)).to.eql(1);
|
||||||
expect(cb).to.be.called();
|
expect(cb).to.be.called();
|
||||||
expect(cb.lastCall.args[0].element).to.eql(1);
|
expect(cb.lastCall.args[0].element).to.eql(1);
|
||||||
@@ -137,11 +137,11 @@ describe('ol.collection', function() {
|
|||||||
it('does dispatch events', function() {
|
it('does dispatch events', function() {
|
||||||
var collection = new ol.Collection(['a', 'b']);
|
var collection = new ol.Collection(['a', 'b']);
|
||||||
var added, removed;
|
var added, removed;
|
||||||
ol.events.listen(collection, ol.CollectionEventType.ADD, function(e) {
|
ol.events.listen(collection, ol.Collection.EventType.ADD, function(e) {
|
||||||
added = e.element;
|
added = e.element;
|
||||||
});
|
});
|
||||||
ol.events.listen(
|
ol.events.listen(
|
||||||
collection, ol.CollectionEventType.REMOVE, function(e) {
|
collection, ol.Collection.EventType.REMOVE, function(e) {
|
||||||
removed = e.element;
|
removed = e.element;
|
||||||
});
|
});
|
||||||
collection.setAt(1, 1);
|
collection.setAt(1, 1);
|
||||||
@@ -155,7 +155,7 @@ describe('ol.collection', function() {
|
|||||||
var collection = new ol.Collection(['a']);
|
var collection = new ol.Collection(['a']);
|
||||||
var removed;
|
var removed;
|
||||||
ol.events.listen(
|
ol.events.listen(
|
||||||
collection, ol.CollectionEventType.REMOVE, function(e) {
|
collection, ol.Collection.EventType.REMOVE, function(e) {
|
||||||
removed = e.element;
|
removed = e.element;
|
||||||
});
|
});
|
||||||
collection.pop();
|
collection.pop();
|
||||||
@@ -168,7 +168,7 @@ describe('ol.collection', function() {
|
|||||||
var collection = new ol.Collection([0, 2]);
|
var collection = new ol.Collection([0, 2]);
|
||||||
var added;
|
var added;
|
||||||
ol.events.listen(
|
ol.events.listen(
|
||||||
collection, ol.CollectionEventType.ADD, function(e) {
|
collection, ol.Collection.EventType.ADD, function(e) {
|
||||||
added = e.element;
|
added = e.element;
|
||||||
});
|
});
|
||||||
collection.insertAt(1, 1);
|
collection.insertAt(1, 1);
|
||||||
@@ -180,7 +180,7 @@ describe('ol.collection', function() {
|
|||||||
it('triggers events properly', function() {
|
it('triggers events properly', function() {
|
||||||
var added = [];
|
var added = [];
|
||||||
ol.events.listen(
|
ol.events.listen(
|
||||||
collection, ol.CollectionEventType.ADD, function(e) {
|
collection, ol.Collection.EventType.ADD, function(e) {
|
||||||
added.push(e.element);
|
added.push(e.element);
|
||||||
});
|
});
|
||||||
collection.setAt(2, 0);
|
collection.setAt(2, 0);
|
||||||
@@ -229,7 +229,7 @@ describe('ol.collection', function() {
|
|||||||
it('triggers add when pushing', function() {
|
it('triggers add when pushing', function() {
|
||||||
var collection = new ol.Collection();
|
var collection = new ol.Collection();
|
||||||
var elem;
|
var elem;
|
||||||
ol.events.listen(collection, ol.CollectionEventType.ADD, function(e) {
|
ol.events.listen(collection, ol.Collection.EventType.ADD, function(e) {
|
||||||
elem = e.element;
|
elem = e.element;
|
||||||
});
|
});
|
||||||
collection.push(1);
|
collection.push(1);
|
||||||
@@ -246,8 +246,8 @@ describe('ol.collection', function() {
|
|||||||
});
|
});
|
||||||
describe('setAt', function() {
|
describe('setAt', function() {
|
||||||
it('triggers remove', function() {
|
it('triggers remove', function() {
|
||||||
ol.events.listen(collection, ol.CollectionEventType.ADD, cb1);
|
ol.events.listen(collection, ol.Collection.EventType.ADD, cb1);
|
||||||
ol.events.listen(collection, ol.CollectionEventType.REMOVE, cb2);
|
ol.events.listen(collection, ol.Collection.EventType.REMOVE, cb2);
|
||||||
collection.setAt(0, 2);
|
collection.setAt(0, 2);
|
||||||
expect(cb2.lastCall.args[0].element).to.eql(1);
|
expect(cb2.lastCall.args[0].element).to.eql(1);
|
||||||
expect(cb1.lastCall.args[0].element).to.eql(2);
|
expect(cb1.lastCall.args[0].element).to.eql(2);
|
||||||
@@ -255,7 +255,7 @@ describe('ol.collection', function() {
|
|||||||
});
|
});
|
||||||
describe('pop', function() {
|
describe('pop', function() {
|
||||||
it('triggers remove', function() {
|
it('triggers remove', function() {
|
||||||
ol.events.listen(collection, ol.CollectionEventType.REMOVE, cb1);
|
ol.events.listen(collection, ol.Collection.EventType.REMOVE, cb1);
|
||||||
collection.pop();
|
collection.pop();
|
||||||
expect(cb1.lastCall.args[0].element).to.eql(1);
|
expect(cb1.lastCall.args[0].element).to.eql(1);
|
||||||
});
|
});
|
||||||
@@ -273,7 +273,7 @@ describe('ol.collection', function() {
|
|||||||
it('fires events', function() {
|
it('fires events', function() {
|
||||||
var collection = new ol.Collection();
|
var collection = new ol.Collection();
|
||||||
var elems = [];
|
var elems = [];
|
||||||
ol.events.listen(collection, ol.CollectionEventType.ADD, function(e) {
|
ol.events.listen(collection, ol.Collection.EventType.ADD, function(e) {
|
||||||
elems.push(e.element);
|
elems.push(e.element);
|
||||||
});
|
});
|
||||||
collection.extend([1, 2]);
|
collection.extend([1, 2]);
|
||||||
@@ -286,4 +286,3 @@ describe('ol.collection', function() {
|
|||||||
|
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.Collection');
|
goog.require('ol.Collection');
|
||||||
goog.require('ol.CollectionEventType');
|
|
||||||
|
|||||||
Reference in New Issue
Block a user