Skip to content

Adjust setView() for each group #931

Description

@aloboa

I need to open the map with a relatively wide extent, but then some groups would
need a more zoomed view. Is there a way to define specific setView() for different groups?
For example, in this example:

library(RStoolbox) #for the example satellite image
library(terra)
library(leaflet)
B4  <- project(rast(system.file("external/landsat/LT52240631988227CUB02_B4.TIF", package="RStoolbox")), "EPSG:4326")
ext(B4)
leaflet() %>% 
  setView(lng = -50.5, lat=-3.4 , zoom = 9) %>%
  addTiles() %>% 
  addProviderTiles(providers$Esri.WorldImagery, group = c("Satview", "Landsat")) %>%
  addRasterImage(B4, group = "Landsat") %>% 
  addLayersControl(
    #baseGroups = c("Satview","OSM","r1","a"),
    baseGroups = c("Satview","Landsat"),
    options = layersControlOptions(collapsed = FALSE, autoZIndex = TRUE))

I would need a "zoom to layer" behaviour when selecting the group Landsat.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions