versatiles-svg-renderer
    Preparing search index...

    Interface PNGMapRendererOptions

    Options for PNGMapRenderer: those of SVGMapRenderer, plus fonts.

    interface PNGMapRendererOptions {
        fetch?: FetchFunction;
        fonts?: Record<string, string>;
        globalState?: GlobalState;
        labels?: LabelMode;
        onWarning?: (message: string) => void;
        renderLabels?: boolean;
        style: StyleSpecification;
        tileCacheSize?: number;
    }

    Hierarchy (View Summary)

    Index

    Loads tiles, sprites, TileJSON documents and GeoJSON data, like fetch, which is the default. Pass your own to send headers, go through a proxy, or keep tiles in a cache on disk.

    It must return a real Response, and its status matters: a 404 or 204 means the server has no such tile, which is remembered (see SVGMapRendererOptions.tileCacheSize); any other error status, or a rejected promise, counts as failed, and the next render tries again.

    the global fetch

    fonts?: Record<string, string>

    Font files to draw labels with, as { "<text-font name>": "<path to a font file>" }. See RenderToPNGOptions.fonts.

    globalState?: GlobalState

    Values for the style's global state, read by global-state expressions, e.g. to switch the language or a theme of a style. They override the defaults in the style's state, like map.setGlobalStateProperty(name, value) in MapLibre GL JS.

    the defaults of the style's state

    labels?: LabelMode

    Whether and how to draw the style's symbol layers, its labels and icons:

    • 'none': neither labels nor icons.
    • 'text': labels as <text> naming the style's fonts (text-font), which whatever displays the SVG resolves, so they show in the intended typeface only where that font is installed. In PNG output, with the fonts given by fonts.
    • 'glyphs': labels as the style's own glyphs (glyphs), the letter shapes MapLibre draws, traced into outlines: exact in every viewer and editor, but not text. Each glyph is defined once and reused.
    • 'glyphs-text': as 'glyphs', with the text laid invisibly over the outlines, so labels stay selectable and searchable. (In PNG output, the same as 'glyphs'.)

    Labels are placed as in MapLibre: at points, inside each polygon at the point farthest from its edges, and along lines; labels and icons that would overlap one placed before are left out, from the top layer down. With glyphs, they are laid out with MapLibre's own metrics; as text, with the widths of Noto Sans. A style without glyphs, or glyphs that cannot be loaded, fall back to 'text', reported through onWarning.

    'none', or as given by SVGMapRendererOptions.renderLabels

    onWarning?: (message: string) => void

    Called with a message for each part of the style the renderer does not draw: a layer type, a layer property, a source, or a TileJSON document that could not be loaded. Each message is reported once per instance. Pass () => {} to silence them.

    Properties that make no difference to a flat, north-up map (e.g. *-pitch-alignment) are not reported, nor are symbol layers unless SVGMapRendererOptions.labels is set.

    console.warn

    renderLabels?: boolean

    Draw the style's labels and icons.

    Use SVGMapRendererOptions.labels: true is 'glyphs-text', false is 'none'.

    false

    style: StyleSpecification

    The MapLibre style to render.

    A source may list its tile URLs (tiles: [...]) or point at a TileJSON document (url: '.../tiles.json'), which is fetched once, like the sprite, with SVGMapRendererOptions.fetch. As in MapLibre GL JS, tiles, minzoom, maxzoom and the like come from the document unless the style sets them, and relative tile URLs are resolved against the document's URL. A GeoJSON source's data may be a URL too. A source whose TileJSON or GeoJSON cannot be loaded is left out, and the next render tries again.

    tileCacheSize?: number

    How much memory the fetched tiles may take, in bytes. Tiles are kept so that rendering an overlapping view does not fetch them again; beyond this size, the least recently used ones are dropped. 0 keeps none.

    Tiles are kept for the lifetime of the instance, regardless of the HTTP caching headers they were served with; see SVGMapRenderer.clearCache.

    134217728 (128 MB)