Skip to content

Commit

Permalink
add group layer controls into the leaflet map
Browse files Browse the repository at this point in the history
  • Loading branch information
osalamon committed Oct 18, 2024
1 parent aa2df58 commit e7224ba
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions app/logic/disease_outbreaks/disease_leaflet_map.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
box::use(
terra[rast, project],
leaflet[leaflet, addTiles, addRasterImage, setView, leafletProxy, removeImage, addRasterLegend, addLegend]
leaflet[tileOptions, leaflet, addTiles, addRasterImage, setView, leafletProxy, removeImage, addRasterLegend, addLegend],
leaflet.extras[addGroupedLayersControl, groupedLayersControlOptions]
)

#' @export
Expand All @@ -14,7 +15,7 @@ disease_leaflet_map <- function(map_raster,
main_map_features = TRUE) {

leaflet_map <- leaflet() |>
addTiles() |>
addTiles(group = "Open Street Map") |>
setView(
lng = 11.8787,
lat = 51.3919,
Expand All @@ -24,15 +25,17 @@ disease_leaflet_map <- function(map_raster,
map_raster,
opacity = 0.9,
project = FALSE,
options = tileOptions(zIndex = 1000),
group = "Disease layer"
) # |>
# addLegend(
# map_raster,
# opacity = 0.9,
# position = "bottomright",
# group = "Diseaselayer",
# className = "info legend Diseaselayer"
# )
) |>
addGroupedLayersControl(
baseGroups = c("Open Street Map", "Disease layer"),
options = groupedLayersControlOptions(
collapsed = FALSE,
exclusiveGroups = "Open Street Map",
groupsCollapsable = FALSE
)
)

return(leaflet_map)
}

0 comments on commit e7224ba

Please sign in to comment.