Listen for layer changes and expire tiles
We need a more flexible event system. We could have a VectorLayerEvent type and dispatch 'featuresadded' here. But listeners want features typically and perhaps extent. This won't be true for all vector layer events (suggesting a more specific VectorFeatureEvent type or something).
This commit is contained in:
@@ -69,6 +69,9 @@ ol.renderer.canvas.VectorLayer = function(mapRenderer, layer) {
|
|||||||
*/
|
*/
|
||||||
this.tileCache_ = new ol.TileCache(
|
this.tileCache_ = new ol.TileCache(
|
||||||
ol.renderer.canvas.VectorLayer.TILECACHE_SIZE);
|
ol.renderer.canvas.VectorLayer.TILECACHE_SIZE);
|
||||||
|
// TODO: this is far too coarse, we want extent of added features
|
||||||
|
goog.events.listenOnce(layer, goog.events.EventType.CHANGE,
|
||||||
|
this.handleLayerChange_, false, this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -139,6 +142,20 @@ ol.renderer.canvas.VectorLayer = function(mapRenderer, layer) {
|
|||||||
goog.inherits(ol.renderer.canvas.VectorLayer, ol.renderer.canvas.Layer);
|
goog.inherits(ol.renderer.canvas.VectorLayer, ol.renderer.canvas.Layer);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get rid cached tiles. If the optional extent is provided, only tiles that
|
||||||
|
* intersect that extent will be removed.
|
||||||
|
* @param {ol.Extent=} opt_extent extent Expire tiles within this extent only.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ol.renderer.canvas.VectorLayer.prototype.expireTiles_ = function(opt_extent) {
|
||||||
|
if (goog.isDef(opt_extent)) {
|
||||||
|
// TODO: implement this
|
||||||
|
}
|
||||||
|
this.tileCache_.clear();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
@@ -163,6 +180,17 @@ ol.renderer.canvas.VectorLayer.prototype.getTransform = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {goog.events.Event} event Layer change event.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ol.renderer.canvas.VectorLayer.prototype.handleLayerChange_ = function(event) {
|
||||||
|
// TODO: get rid of this in favor of vector specific events
|
||||||
|
this.expireTiles_();
|
||||||
|
this.requestMapRenderFrame_();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user