Thanks for that link.
I have now updated my toy example to work in a shiny map.
library(mapedit)
library(leaflet)
ui <- fluidPage(
selectModUI("eview")
)
server <- function(input, output) {
ns <<- shiny::NS("eview")
lf0 <- leaflet() %>%
addTiles()%>%
addPolygons(data =gadmCHE,
label = ~NAME_1,
layerId = ~NAME_1)
callModule(selectMod, "eview", lf0)
}
shinyApp(ui = ui, server = server)
However , without the ability to use renderleaflet or leafeler proxy I cannot turn this toy example into what I actually need to do.
I want to be able to turn on and off overlays of polygons on the map and at the same time swithc on and off the ability to select the the polygons ( through a sidebar radio button for example)
I tried the following but it does not display the polygons or ability to select. can you suggest how I "overlay a selectMod on the leaflet map, use it for selection , and then remove the overlay?
library(mapedit)
library(leaflet)
library(raster)
options(shiny.trace=TRUE)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
radioButtons(inputId = "SelectionOn",inline = T,choiceNames = c("No","Yes"),choiceValues = c(0,1),label="Do you want to display polygons for selection")
),
mainPanel(
selectModUI("eview",height=900)
)
)
)
server <- function(input, output) {
ns <- NS("eview")
lf0 <- leaflet() %>%
addTiles()
observe({
if (input$SelectionOn==1){
leafletProxy("map")%>%
addPolygons(data =gadmCHE,
label = ~NAME_1,
layerId = ~NAME_1,
group ="myPolygons")
callModule(selectMod, "eview", lf0)
} else {leafletProxy("map")%>%
hideGroup("myPolygons")
callModule(selectMod, "eview", lf0)
}
})
}
shinyApp(ui = ui, server = server)