Layer is now responsible of its rendering

This commit is contained in:
Florent gravin
2018-11-13 12:23:53 +01:00
parent d21a88edce
commit c2c599a517
2 changed files with 15 additions and 5 deletions

View File

@@ -172,6 +172,20 @@ class Layer extends BaseLayer {
this.changed();
}
/**
* In charge to manage the rendering of the layer. One layer type is
* bounded with one layer renderer.
* @param {?import("../PluggableMap.js").FrameState} frameState Frame state.
* @return {HTMLElement} The rendered element.
*/
render(frameState) {
const layerRenderer = this.getRenderer();
const layerState = this.getLayerState();
if (layerRenderer.prepareFrame(frameState, layerState)) {
return layerRenderer.renderFrame(frameState, layerState);
}
}
/**
* Sets the layer to be rendered on top of other layers on a map. The map will
* not manage this layer in its layers collection, and the callback in

View File

@@ -96,11 +96,7 @@ class CompositeMapRenderer extends MapRenderer {
}
const layer = layerState.layer;
const layerRenderer = this.getLayerRenderer(layer);
if (layerRenderer.prepareFrame(frameState, layerState)) {
const element = layerRenderer.renderFrame(frameState, layerState);
this.children_.push(element);
}
this.children_.push(layer.render(frameState));
}
replaceChildren(this.element_, this.children_);