Skip to content

applyDocumentBase

applyDocumentBase(model, base): MapModel

Defined in: packages/core/src/utils/document-base.ts:336

Resolve every URL in a normalized map document against base.

ParameterTypeDescription
modelMapModelThe document as toModel returns it (v1 and v2 both normalize to this shape).
basestring | null | undefinedThe document base (any form normalizeDocumentBase accepts). Without one the model is returned as is.

MapModel

A model whose URL fields are resolved — the input when nothing changed. Never mutates the input, and never adds a key.

The fields, from the schemas:

WhereField
config.mapStyle / style.basemapthe style URL; for an inline style object, its sprite, glyphs and sources; for a Protomaps basemap, its pmtiles, glyphs and sprite
sources.* and inline layers[].sourceurl, tiles[], urls[] (video), data when it is a string, stream.url
images.*the URL string, or url
markers[]icon, and hrefs in its popup
layers[].interactivehrefs in hover.popup / click.popup
popups[]hrefs in content

Not URLs, so not touched: legend icon (rendered as text), popup image src (absolute URLs only), fitTo.source / terrain.source (source names), and anything inside an external style JSON or GeoJSON file.