Skipped features replaces RenderGeometryFunction
This commit is contained in:
@@ -1,18 +1,15 @@
|
||||
goog.provide('ol.layer.Vector');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.events');
|
||||
goog.require('goog.events.EventType');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.Collection');
|
||||
goog.require('ol.CollectionEventType');
|
||||
goog.require('ol.feature');
|
||||
goog.require('ol.layer.Layer');
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
ol.layer.VectorProperty = {
|
||||
RENDER_GEOMETRY_FUNCTIONS: 'renderGeometryFunctions'
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -48,24 +45,29 @@ ol.layer.Vector = function(opt_options) {
|
||||
this.setStyle(options.style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Collection of Features to skip drawing.
|
||||
* @type {ol.Collection}
|
||||
* @private
|
||||
*/
|
||||
this.skippedFeatures_ = new ol.Collection();
|
||||
|
||||
/**
|
||||
* Array of Feature ids to skip drawing.
|
||||
* @type {Array.<number>}
|
||||
* @private
|
||||
*/
|
||||
this.skippedFeaturesIds_ = [];
|
||||
|
||||
goog.events.listen(this.skippedFeatures_, [
|
||||
ol.CollectionEventType.REMOVE,
|
||||
ol.CollectionEventType.ADD
|
||||
], this.updateSkippedFeaturesArray_, false, this);
|
||||
|
||||
};
|
||||
goog.inherits(ol.layer.Vector, ol.layer.Layer);
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.Collection|undefined} Render geometry functions.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.layer.Vector.prototype.getRenderGeometryFunctions = function() {
|
||||
return /** @type {ol.Collection|undefined} */ (
|
||||
this.get(ol.layer.VectorProperty.RENDER_GEOMETRY_FUNCTIONS));
|
||||
};
|
||||
goog.exportProperty(
|
||||
ol.layer.Vector.prototype,
|
||||
'getRenderGeometryFunctions',
|
||||
ol.layer.Vector.prototype.getRenderGeometryFunctions);
|
||||
|
||||
|
||||
/**
|
||||
* Get the style for features. This returns whatever was passed to the `style`
|
||||
* option at construction or to the `setStyle` method.
|
||||
@@ -87,22 +89,6 @@ ol.layer.Vector.prototype.getStyleFunction = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Collection|undefined} renderGeometryFunctions Render geometry
|
||||
* functions.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.layer.Vector.prototype.setRenderGeometryFunctions =
|
||||
function(renderGeometryFunctions) {
|
||||
this.set(ol.layer.VectorProperty.RENDER_GEOMETRY_FUNCTIONS,
|
||||
renderGeometryFunctions);
|
||||
};
|
||||
goog.exportProperty(
|
||||
ol.layer.Vector.prototype,
|
||||
'setRenderGeometryFunctions',
|
||||
ol.layer.Vector.prototype.setRenderGeometryFunctions);
|
||||
|
||||
|
||||
/**
|
||||
* Set the style for features. This can be a single style object, an array
|
||||
* of styles, or a function that takes a feature and resolution and returns
|
||||
@@ -116,3 +102,36 @@ ol.layer.Vector.prototype.setStyle = function(style) {
|
||||
this.styleFunction_ = ol.feature.createStyleFunction(style);
|
||||
this.dispatchChangeEvent();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Update Features Ids internal array.
|
||||
* @private
|
||||
*/
|
||||
ol.layer.Vector.prototype.updateSkippedFeaturesArray_ = function() {
|
||||
this.skippedFeaturesIds_ = goog.array.map(
|
||||
this.skippedFeatures_.getArray(), goog.getUid);
|
||||
// Don’t use dispatchChangeEvent here because we don’t want the batch
|
||||
// to be re-created, just replayed.
|
||||
this.dispatchEvent(goog.events.EventType.CHANGE);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the collection of features to be skipped.
|
||||
* @return {ol.Collection} Features collection.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.layer.Vector.prototype.getSkippedFeatures = function() {
|
||||
return this.skippedFeatures_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the feature’s ids to be skipped.
|
||||
* @return {Array.<number>} Array of features Ids
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.layer.Vector.prototype.getSkippedFeaturesIds = function() {
|
||||
return this.skippedFeaturesIds_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user