Create and remove layer renderers in renderFrame

Previously, the map renderer would listen for layers being added and
removed from the layers collection, and would create and remove layer
renderers in response to these events.

With this change, layer renderers are only created or removed when
renderFrame is called, which leads to somewhat simpler code.

We still need to listen to changes to the layers collection, but now
these only trigger a new render.

This new approach also has an advantage when layers change order.
Swapping the order of two layers involves removing one and re-inserting
it elsewhere.  With the old approach, this would cause the deletion and
re-creation of the layer renderer.  With this new approach, the layer
renderer is preserved.
This commit is contained in:
Tom Payne
2013-04-12 17:50:33 +02:00
parent be629a7ed8
commit 4e69b2bb8b
4 changed files with 55 additions and 69 deletions

View File

@@ -153,4 +153,6 @@ ol.renderer.canvas.Map.prototype.renderFrame = function(frameState) {
this.renderedVisible_ = true;
}
this.removeUnusedLayerRenderers(frameState);
};