Created
January 21, 2020 11:04
-
-
Save PaulC91/072fa15154bdc716be639e433dbc74df to your computer and use it in GitHub Desktop.
different options for rendering tiles in R leaflet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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