Shared module for vector event type enum
This commit is contained in:
@@ -9,10 +9,11 @@ goog.require('ol.coordinate');
|
|||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.interaction.Pointer');
|
|
||||||
goog.require('ol.functions');
|
goog.require('ol.functions');
|
||||||
|
goog.require('ol.interaction.Pointer');
|
||||||
goog.require('ol.obj');
|
goog.require('ol.obj');
|
||||||
goog.require('ol.source.Vector');
|
goog.require('ol.source.Vector');
|
||||||
|
goog.require('ol.source.VectorEventType');
|
||||||
goog.require('ol.structs.RBush');
|
goog.require('ol.structs.RBush');
|
||||||
|
|
||||||
|
|
||||||
@@ -343,9 +344,9 @@ ol.interaction.Snap.prototype.setMap = function(map) {
|
|||||||
);
|
);
|
||||||
} else if (this.source_) {
|
} else if (this.source_) {
|
||||||
keys.push(
|
keys.push(
|
||||||
ol.events.listen(this.source_, ol.source.Vector.EventType.ADDFEATURE,
|
ol.events.listen(this.source_, ol.source.VectorEventType.ADDFEATURE,
|
||||||
this.handleFeatureAdd_, this),
|
this.handleFeatureAdd_, this),
|
||||||
ol.events.listen(this.source_, ol.source.Vector.EventType.REMOVEFEATURE,
|
ol.events.listen(this.source_, ol.source.VectorEventType.REMOVEFEATURE,
|
||||||
this.handleFeatureRemove_, this)
|
this.handleFeatureRemove_, this)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ goog.require('ol.loadingstrategy');
|
|||||||
goog.require('ol.obj');
|
goog.require('ol.obj');
|
||||||
goog.require('ol.source.Source');
|
goog.require('ol.source.Source');
|
||||||
goog.require('ol.source.State');
|
goog.require('ol.source.State');
|
||||||
|
goog.require('ol.source.VectorEventType');
|
||||||
goog.require('ol.structs.RBush');
|
goog.require('ol.structs.RBush');
|
||||||
|
|
||||||
|
|
||||||
@@ -191,7 +192,7 @@ ol.source.Vector.prototype.addFeatureInternal = function(feature) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new ol.source.Vector.Event(ol.source.Vector.EventType.ADDFEATURE, feature));
|
new ol.source.Vector.Event(ol.source.VectorEventType.ADDFEATURE, feature));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -288,7 +289,7 @@ ol.source.Vector.prototype.addFeaturesInternal = function(features) {
|
|||||||
|
|
||||||
for (i = 0, length = newFeatures.length; i < length; i++) {
|
for (i = 0, length = newFeatures.length; i < length; i++) {
|
||||||
this.dispatchEvent(new ol.source.Vector.Event(
|
this.dispatchEvent(new ol.source.Vector.Event(
|
||||||
ol.source.Vector.EventType.ADDFEATURE, newFeatures[i]));
|
ol.source.VectorEventType.ADDFEATURE, newFeatures[i]));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -301,7 +302,7 @@ ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) {
|
|||||||
ol.DEBUG && console.assert(!this.featuresCollection_,
|
ol.DEBUG && console.assert(!this.featuresCollection_,
|
||||||
'bindFeaturesCollection can only be called once');
|
'bindFeaturesCollection can only be called once');
|
||||||
var modifyingCollection = false;
|
var modifyingCollection = false;
|
||||||
ol.events.listen(this, ol.source.Vector.EventType.ADDFEATURE,
|
ol.events.listen(this, ol.source.VectorEventType.ADDFEATURE,
|
||||||
function(evt) {
|
function(evt) {
|
||||||
if (!modifyingCollection) {
|
if (!modifyingCollection) {
|
||||||
modifyingCollection = true;
|
modifyingCollection = true;
|
||||||
@@ -309,7 +310,7 @@ ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) {
|
|||||||
modifyingCollection = false;
|
modifyingCollection = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ol.events.listen(this, ol.source.Vector.EventType.REMOVEFEATURE,
|
ol.events.listen(this, ol.source.VectorEventType.REMOVEFEATURE,
|
||||||
function(evt) {
|
function(evt) {
|
||||||
if (!modifyingCollection) {
|
if (!modifyingCollection) {
|
||||||
modifyingCollection = true;
|
modifyingCollection = true;
|
||||||
@@ -377,7 +378,7 @@ ol.source.Vector.prototype.clear = function(opt_fast) {
|
|||||||
this.loadedExtentsRtree_.clear();
|
this.loadedExtentsRtree_.clear();
|
||||||
this.nullGeometryFeatures_ = {};
|
this.nullGeometryFeatures_ = {};
|
||||||
|
|
||||||
var clearEvent = new ol.source.Vector.Event(ol.source.Vector.EventType.CLEAR);
|
var clearEvent = new ol.source.Vector.Event(ol.source.VectorEventType.CLEAR);
|
||||||
this.dispatchEvent(clearEvent);
|
this.dispatchEvent(clearEvent);
|
||||||
this.changed();
|
this.changed();
|
||||||
};
|
};
|
||||||
@@ -740,7 +741,7 @@ ol.source.Vector.prototype.handleFeatureChange_ = function(event) {
|
|||||||
}
|
}
|
||||||
this.changed();
|
this.changed();
|
||||||
this.dispatchEvent(new ol.source.Vector.Event(
|
this.dispatchEvent(new ol.source.Vector.Event(
|
||||||
ol.source.Vector.EventType.CHANGEFEATURE, feature));
|
ol.source.VectorEventType.CHANGEFEATURE, feature));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -820,7 +821,7 @@ ol.source.Vector.prototype.removeFeatureInternal = function(feature) {
|
|||||||
delete this.undefIdIndex_[featureKey];
|
delete this.undefIdIndex_[featureKey];
|
||||||
}
|
}
|
||||||
this.dispatchEvent(new ol.source.Vector.Event(
|
this.dispatchEvent(new ol.source.Vector.Event(
|
||||||
ol.source.Vector.EventType.REMOVEFEATURE, feature));
|
ol.source.VectorEventType.REMOVEFEATURE, feature));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -868,38 +869,3 @@ ol.source.Vector.Event = function(type, opt_feature) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.source.Vector.Event, ol.events.Event);
|
ol.inherits(ol.source.Vector.Event, ol.events.Event);
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
ol.source.Vector.EventType = {
|
|
||||||
/**
|
|
||||||
* Triggered when a feature is added to the source.
|
|
||||||
* @event ol.source.Vector.Event#addfeature
|
|
||||||
* @api stable
|
|
||||||
*/
|
|
||||||
ADDFEATURE: 'addfeature',
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Triggered when a feature is updated.
|
|
||||||
* @event ol.source.Vector.Event#changefeature
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
CHANGEFEATURE: 'changefeature',
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Triggered when the clear method is called on the source.
|
|
||||||
* @event ol.source.Vector.Event#clear
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
CLEAR: 'clear',
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Triggered when a feature is removed from the source.
|
|
||||||
* See {@link ol.source.Vector#clear source.clear()} for exceptions.
|
|
||||||
* @event ol.source.Vector.Event#removefeature
|
|
||||||
* @api stable
|
|
||||||
*/
|
|
||||||
REMOVEFEATURE: 'removefeature'
|
|
||||||
};
|
|
||||||
|
|||||||
35
src/ol/source/vectoreventtype.js
Normal file
35
src/ol/source/vectoreventtype.js
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
goog.provide('ol.source.VectorEventType');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
ol.source.VectorEventType = {
|
||||||
|
/**
|
||||||
|
* Triggered when a feature is added to the source.
|
||||||
|
* @event ol.source.Vector.Event#addfeature
|
||||||
|
* @api stable
|
||||||
|
*/
|
||||||
|
ADDFEATURE: 'addfeature',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggered when a feature is updated.
|
||||||
|
* @event ol.source.Vector.Event#changefeature
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
CHANGEFEATURE: 'changefeature',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggered when the clear method is called on the source.
|
||||||
|
* @event ol.source.Vector.Event#clear
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
CLEAR: 'clear',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggered when a feature is removed from the source.
|
||||||
|
* See {@link ol.source.Vector#clear source.clear()} for exceptions.
|
||||||
|
* @event ol.source.Vector.Event#removefeature
|
||||||
|
* @api stable
|
||||||
|
*/
|
||||||
|
REMOVEFEATURE: 'removefeature'
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user