Skip to content

Basemaps

maplibre.basemaps.Carto

Bases: Enum

Carto basemap styles

Attributes:

  • DARK_MATTER

    dark-matter

  • POSITRON

    positron

  • VOYAGER

    voyager

  • POSITRON_NOLABELS

    positron-nolabels

  • DARK_MATTER_NOLABELS

    dark-matter-nolabels

  • VOYAGER_NOLABELS

    voyager-nolabels

Examples:

>>> from maplibre import Map, MapOptions
>>> from maplibre.basemaps import Carto
>>> map = Map(MapOptions(style=Carto.DARK_MATTER))
Source code in maplibre/basemaps.py
class Carto(Enum):
    """Carto basemap styles

    Attributes:
        DARK_MATTER: dark-matter
        POSITRON: positron
        VOYAGER: voyager
        POSITRON_NOLABELS: positron-nolabels
        DARK_MATTER_NOLABELS: dark-matter-nolabels
        VOYAGER_NOLABELS: voyager-nolabels

    Examples:
        >>> from maplibre import Map, MapOptions
        >>> from maplibre.basemaps import Carto

        >>> map = Map(MapOptions(style=Carto.DARK_MATTER))
    """

    DARK_MATTER = "dark-matter"
    POSITRON = "positron"
    VOYAGER = "voyager"
    POSITRON_NOLABELS = "positron-nolabels"
    DARK_MATTER_NOLABELS = "dark-matter-nolabels"
    VOYAGER_NOLABELS = "voyager-nolabels"

maplibre.basemaps.construct_basemap_style(name='nice-style', sources={}, layers=[])

Construct a basemap style

Parameters:

Name Type Description Default
name str

The name of the basemap style.

'nice-style'
sources dict

The sources to be used for the basemap style.

{}
layers list

The layers to be used for the basemap style.

[]
Source code in maplibre/basemaps.py
def construct_basemap_style(
    name: str = "nice-style", sources: dict = {}, layers: list = []
) -> dict:
    """Construct a basemap style

    Args:
        name (str): The name of the basemap style.
        sources (dict): The sources to be used for the basemap style.
        layers (list): The layers to be used for the basemap style.
    """
    layers = [
        layer.to_dict() if isinstance(layer, Layer) else layer for layer in layers
    ]
    return {"name": name, "version": 8, "sources": sources, "layers": layers}