Skip to main content

Module render

Module render 

Source
Expand description

Render decoded vector tiles with a MapLibre style, modelling MapLibre GL JS’s WebGL pipeline in software (see gl.rs).

The view is centred on the bbox centre at MapLibre’s scale zoom (512 px tiles), exactly as MapLibre’s transform places it. Layers are drawn in style order; fill and line fragments are clipped to their tile’s square (MapLibre’s stencil test). Circles are not clipped; points outside the tile are dropped, as MapLibre’s CircleBucket does.

Structs§

RasterTiles
Raster tiles of one source at the zoom MapLibre covers the view with.
RenderOutput
SourceTiles
Tiles for every tile source a style’s layers use, keyed by source id. Vector tiles carry their world-copy wrap (see covering_tiles).
SvgParts
One style rendered as SVG fragments (ids prefixed so several styles can share one document).

Constants§

TILE_PX
MapLibre vector tiles are laid out on a 512 px grid.

Functions§

covering_tiles
Tiles covering bbox at tile zoom z, as (canonical tile, wrap). Columns past ±180° belong to a wrapped world copy: wrap -1 is the copy to the west, +1 to the east (MapLibre’s renderWorldCopies).
device_px
Device pixels for css CSS pixels at ratio (MapLibre’s drawing buffer is the canvas size times devicePixelRatio).
render
Render tiles (raw MVT bytes) with style over bbox at width × height. assets holds glyphs and sprite images for symbol layers (may be empty). Each tile carries its world-copy wrap (see covering_tiles). width and height are CSS pixels; the image is ratio times larger (MapLibre’s devicePixelRatio: same view and layout, drawn denser).
render_svg
Render tiles with style as vector SVG: the same view, tile clipping, evaluated style values and label placement as render, written as paths instead of pixels. Labels are glyph outlines traced from the style’s SDF glyphs at the shader’s edge threshold.
scale_zoom
MapLibre’s scale zoom for a bbox drawn width pixels wide.
tile_zoom
Tile zoom MapLibre would request for a vector source at this view.