Skip to content

Enable viewing of locally saved pmtiles #73

@Robinlovelace

Description

@Robinlovelace

I've just tried the following to no avail:

library(leafem)
library(leaflet)
url_rivers = "https://vector-tiles-data.s3.eu-central-1.amazonaws.com/rivers_africa.pmtiles"
leaflet() %>%
  addTiles() %>%
  addPMPolylines(
    url = url_rivers
    , layerId = "rivers"
    , group = "rivers"
    , style = paintRules(
      layer = "rivers_africa"
      , color = "blue"
    )
  ) %>%
  setView(24, 2.5, 4)
f_rivers = basename(url_rivers)
if (!file.exists(f_rivers)) {
  download.file(url_rivers, f_rivers)
}
leaflet() %>%
  addTiles() %>%
  addPMPolylines(
    # url = paste0("pmtiles://", f_rivers)
    url = f_rivers
    , layerId = "rivers"
    , group = "rivers"
    , style = paintRules(
      layer = "rivers_africa"
      , color = "blue"
    )
  ) %>%
  setView(24, 2.5, 4)

I know that hosting pmtiles locally can work: protomaps/PMTiles#234

Thoughts @tim-salabim or anyone? Would be super useful if possible and imagine it would work as a simple solution when shipping a .pmtiles file alongside a map for a quick solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions