Skip to content

save_map(hide_controls = TRUE) does not reliably hide controls when using add_pmtiles_source() #190

@danielvartan

Description

@danielvartan

Summary

mapgl::save_map() hides map controls correctly for many maps, but when the map includes a PMTiles source via add_pmtiles_source(), controls can still appear in the exported PNG even with hide_controls = TRUE.

Reproducible Example

library(mapgl)

map <- 
  maplibre(
    bounds = c(-73.99045, -33.75118, -28.84764, 5.271841)
  ) |>
  add_pmtiles_source(
    id = "state_boundaries",
    url = "https://tiles.pmtiles.com.br/geobr/read_state/code-all-year-2020-simplified-TRUE-min_zoom-2-max_zoom-10.pmtiles"
  ) |>
  add_fill_layer(
    id = "fill",
    source = "state_boundaries",
    source_layer = "read_state",
    fill_color = "blue"
  ) |>
  add_navigation_control()

map |>
  save_map(
    filename = "pmtiles_map.png",
    hide_controls = TRUE
  )

Image:

Image

Expected Behavior

Controls are hidden in the output image when hide_controls = TRUE.

Actual Behavior

When PMTiles is used, some controls remain visible in the saved image.

Environment

devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.5.3 (2026-03-11)
#>  os       Arch Linux
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language en
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       America/Sao_Paulo
#>  date     2026-04-05
#>  pandoc   3.6.3 @ /usr/share/positron/resources/app/quarto/bin/tools/x86_64/ (via rmarkdown)
#>  quarto   1.8.27 @ /opt/quarto/bin/quarto
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  cachem        1.1.0   2024-05-16 [1] CRAN (R 4.5.1)
#>  cli           3.6.5   2025-04-23 [1] CRAN (R 4.5.2)
#>  devtools      2.4.6   2025-10-03 [1] CRAN (R 4.5.2)
#>  digest        0.6.39  2025-11-19 [1] CRAN (R 4.5.2)
#>  ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.5.1)
#>  evaluate      1.0.5   2025-08-27 [1] CRAN (R 4.5.1)
#>  fastmap       1.2.0   2024-05-15 [1] CRAN (R 4.5.1)
#>  fs            1.6.6   2025-04-12 [1] CRAN (R 4.5.2)
#>  glue          1.8.0   2024-09-30 [1] CRAN (R 4.5.1)
#>  htmltools     0.5.9   2025-12-04 [1] CRAN (R 4.5.2)
#>  knitr         1.51    2025-12-20 [1] CRAN (R 4.5.2)
#>  lifecycle     1.0.5   2026-01-08 [1] CRAN (R 4.5.2)
#>  magrittr      2.0.4   2025-09-12 [1] CRAN (R 4.5.2)
#>  memoise       2.0.1   2021-11-26 [1] CRAN (R 4.5.1)
#>  otel          0.2.0   2025-08-29 [1] CRAN (R 4.5.2)
#>  pkgbuild      1.4.8   2025-05-26 [1] CRAN (R 4.5.1)
#>  pkgload       1.5.0   2026-02-03 [1] CRAN (R 4.5.2)
#>  purrr         1.2.1   2026-01-09 [1] CRAN (R 4.5.2)
#>  R6            2.6.1   2025-02-15 [1] CRAN (R 4.5.1)
#>  remotes       2.5.0   2024-03-17 [1] CRAN (R 4.5.2)
#>  reprex        2.1.1   2024-07-06 [1] CRAN (R 4.5.1)
#>  rlang         1.1.7   2026-01-09 [1] CRAN (R 4.5.2)
#>  rmarkdown     2.30    2025-09-28 [1] CRAN (R 4.5.2)
#>  sessioninfo   1.2.3   2025-02-05 [1] CRAN (R 4.5.1)
#>  usethis       3.2.1   2025-09-06 [1] CRAN (R 4.5.2)
#>  vctrs         0.7.1   2026-01-23 [1] CRAN (R 4.5.2)
#>  withr         3.0.2   2024-10-28 [1] CRAN (R 4.5.2)
#>  xfun          0.56    2026-01-18 [1] CRAN (R 4.5.2)
#>  yaml          2.3.12  2025-12-10 [1] CRAN (R 4.5.2)
#> 
#>  [1] /home/danielvartan/R/x86_64-pc-linux-gnu-library/4.5
#>  [2] /usr/lib/R/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Created on 2026-04-05 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions