Skip to contents

Create a basemap style definition

Usage

construct_basemap_style(sources, layers, name = "custom-basemap")

Arguments

sources

The sources to be used for the basemap style.

layers

The layers to be used for the basemap style.

name

The name of the basemap style.

Value

list

Examples

PMTILES_URL <- "https://pmtiles.io/protomaps(vector)ODbL_firenze.pmtiles"

pmtiles_source <- list(
  type = "vector",
  url = glue::glue("pmtiles://{PMTILES_URL}"),
  attribution = '© <a href="https://openstreetmap.org">OpenStreetMap</a>'
)

sources <- list(pmtiles = pmtiles_source)

landuse <- Layer(
  id = "buildings",
  source = "pmtiles",
  "source-layer" = "landuse",
  type = LayerType$FILL,
  paint = list("fill-color" = "steelblue")
)

roads <- Layer(
  id = "roads",
  source = "pmtiles",
  "source-layer" = "roads",
  type = LayerType$LINE,
  paint = list("line-color" = "black"),
)

custom_basemap <- construct_basemap_style(
  sources,
  layers = list(landuse, roads)
)

setup <- mapOptions(
  style = custom_basemap,
  bounds = list(11.154026, 43.7270125, 11.3289395, 43.8325455)
)

maplibre(setup)