Skip to content

Layer Architecture

This document covers the layer architecture in OpenLayers, including the different layer types (Vector, Tile, Image, WebGL) and how they integrate with the rendering system. Layers serve as the bridge between data sources and the rendering pipeline, organizing geospatial content for display.

For information about the central Map component that orchestrates layers, see Map Component. For details about data sources that feed into layers, see Source System. For specifics on the rendering pipeline that layers integrate with, see Rendering System.

Layer Type Hierarchy

OpenLayers supports several layer types, each optimized for different types of geospatial data and rendering requirements. The layer types form a hierarchy that determines their rendering behavior and data handling capabilities.

SVG
100%

Layer Type Characteristics:

Layer TypeData FormatRendering MethodUse Cases
VectorLayerFeatures with geometriesCanvas 2D drawingInteractive features, editing
TileLayerPre-rendered image tilesCanvas image drawingBase maps, raster overlays
ImageLayerSingle imagesCanvas image drawingWMS, static imagery
VectorTileLayerTiled vector dataCanvas 2D or pre-renderedScalable vector maps
VectorImageLayerVector rendered to imageCanvas image drawingPerformance optimization
WebGLLayerAny, GPU processedWebGL shadersLarge datasets, effects

Renderer Architecture

Each layer type is paired with a corresponding renderer that handles the actual drawing operations. The renderer architecture follows a hierarchical pattern with shared base functionality and specialized implementations.

SVG
100%

Core Renderer Responsibilities:

  • LayerRenderer: Abstract interface defining prepareFrame(), renderFrame(), and hit detection methods
  • CanvasLayerRenderer: Canvas context management, transform calculations, container preparation
  • Specialized Renderers: Layer-type-specific rendering logic and optimizations

Layer-Renderer Integration Pipeline

The layer rendering process follows a consistent pipeline that integrates with the Map's frame rendering cycle. Each renderer implements this pipeline according to its layer type's requirements.

SVG
100%

Pipeline Stages:

  1. Preparation (src/ol/renderer/Layer.js90-92): Determine if layer is ready to render
  2. Frame Setup (src/ol/renderer/canvas/Layer.js252-287): Configure canvas transforms and clipping
  3. Content Rendering: Layer-specific drawing operations
  4. Cleanup (src/ol/renderer/canvas/Layer.js326-331): Dispatch events and finalize rendering

Tile Layer Implementation

The CanvasTileLayerRenderer implements sophisticated tile management including caching, alternative zoom level handling, and efficient rendering of tile pyramids.

SVG
100%

Key Tile Rendering Features:

Vector Layer Implementation

The CanvasVectorLayerRenderer handles feature-based rendering with support for styling, hit detection, and world wrapping for global projections.

SVG
100%

Vector Rendering Pipeline:

  1. Feature Loading (src/ol/renderer/canvas/VectorLayer.js676-690): Spatial query for features in view extent
  2. Style Application (src/ol/renderer/canvas/VectorLayer.js700-718): Apply feature or layer styles
  3. Instruction Building (src/ol/renderer/canvas/VectorLayer.js666-671): Convert features to drawing instructions
  4. Rendering Execution (src/ol/renderer/canvas/VectorLayer.js221-236): Execute instructions with world wrapping

Vector Tile Layer Implementation

The CanvasVectorTileLayerRenderer combines tile-based loading with vector rendering, supporting multiple source tiles per render tile and efficient caching.

SVG
100%

Vector Tile Rendering Features:

Layer Integration with Map Rendering

Layers integrate with the Map's rendering system through the LayerRenderer interface, participating in the frame rendering cycle and coordinate transformations.

SVG
100%

Integration Points: