Skip to content

Instantly share code, notes, and snippets.

@walkerke
Created November 9, 2025 15:45
Show Gist options
  • Select an option

  • Save walkerke/648402074451eae4ad43c648b236f966 to your computer and use it in GitHub Desktop.

Select an option

Save walkerke/648402074451eae4ad43c648b236f966 to your computer and use it in GitHub Desktop.
library(mapgl)
library(sf)
nc <- st_read(system.file("shape/nc.shp", package = "sf"))
# Custom style with background-pattern
style <- list(
version = 8,
sources = structure(list(), .Names = character(0)),
layers = list(
list(
id = "background",
type = "background",
paint = list(
`background-pattern` = "parchment"
)
)
)
)
maplibre(style = style) |>
fit_bounds(nc) |>
add_image(
id = "parchment",
url = "parchment.jpg" # Your image - find a free stock photo online to try
) |>
add_line_layer(
id = "counties",
source = nc,
line_color = "#2c1810",
line_width = 1.5
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment