mapview icon indicating copy to clipboard operation
mapview copied to clipboard

Mapview - Can we set the radiobuttons also for the raster data?

Open agronomofiorentini opened this issue 2 years ago • 3 comments

Dear creators, First of all thanks to have build this amazing package, at least once a day I use mapview.

I would like to ask if it is possible to be able to include an argument that allows users to define whether we want to have raster data with checkboxes or radiobuttons.

image

I am asking because this allows us to be able to view one raster map at a time and not all togheter.

Thanks, and i hope this can help others.

agronomofiorentini avatar Sep 12 '23 14:09 agronomofiorentini

I think this would need to be implemented in leaflet, rather than here. IIRC there's already an issue on the leaflet github repo asking for this. Did you have a look there?

tim-salabim avatar Sep 12 '23 14:09 tim-salabim

Dear @tim-salabim, always ready to help.

I haven't had a look yet to the leaflet github repo actually and i will take a look. Anyway thanks.

agronomofiorentini avatar Sep 12 '23 15:09 agronomofiorentini

@tim-salabim

I have this code that i want to show you and it's full reproducible code

library(plainview)
library(leaflet)

poppendorf

map<-leaflet() %>%
  leaflet::addProviderTiles(provider = providers$OpenStreetMap, group = "Google Maps") %>%
  leaflet::addProviderTiles(provider = providers$Esri.WorldImagery, group = "Satellite")

names<-names(poppendorf)

for (i in seq(from=1,by=1,to=length(names))) {
  map<-map %>%
    addRasterImage(poppendorf[[names[i]]], group = names[i])
}

There are three different options that don't allow us to set what we would like to achieve "A leaflet map that allow us to have radiobuttons for both baseGroups and overlayGroups "

1

map<-map %>%
  addLayersControl(
    position = c("topleft"),
    baseGroups = names,
    overlayGroups = c("Satellite", "Google Maps"),
    options = layersControlOptions(collapsed = F, autoZIndex = F)
  )

map

2

map<-map %>%
  addLayersControl(
    position = c("topleft"),
    baseGroups = c("Satellite", "Google Maps", names),
    options = layersControlOptions(collapsed = F, autoZIndex = F)
  )

map

3

map<-map %>%
  addLayersControl(
    position = c("topleft"),
    baseGroups = c("Satellite", "Google Maps", names),
    options = layersControlOptions(collapsed = F, autoZIndex = F)
  )

map

Can you please paste here below the link of the github issue that you refered before?

agronomofiorentini avatar Sep 14 '23 13:09 agronomofiorentini