Skip to content

Instantly share code, notes, and snippets.

@PaulC91
Created January 21, 2020 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PaulC91/072fa15154bdc716be639e433dbc74df to your computer and use it in GitHub Desktop.
Save PaulC91/072fa15154bdc716be639e433dbc74df to your computer and use it in GitHub Desktop.
different options for rendering tiles in R leaflet
# OSM tile with no labels
osm_nolabels <- "https://tiles.wmflabs.org/osm-no-labels/{z}/{x}/{y}.png"
# OSM humanitarian tile (just for ref)
osm_hot <- "http://a.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png"
# if you a mapping a choropleth with polygons, this will render place labels above the polygons
leaflet() %>%
addMapPane(name = "polygons", zIndex = 410) %>%
addMapPane(name = "maplabels", zIndex = 420) %>% # higher zIndex rendered on top
addTiles(urlTemplate = osm_nolabels) %>%
addProviderTiles("CartoDB.PositronOnlyLabels", options = leafletOptions(pane = "maplabels"), group = "Place names") %>%
addPolygons(...) %>%
addLayersControl(overlayGroups = c("Place names"), options = layersControlOptions(collapsed = FALSE))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment