Hello,
For reason I do not understand, leaflet maps are not displaying when wrapped into a module. They display just fine when in the main ui.R and server.R files. It's a big app, so it's my preference to modularize this, if possible.
Any ideas what is going on?
Here is a reprex:
### global conditions ####
library(shiny); library(shinydashboard); library(leaflet)
### modular functions ####
# UI file
extra_UI <- function(id) {
ns = NS(id)
fluidRow(leafletOutput("myMap"))
}
# server file
extra_server <- function(input, output, session) {
ns <- session$ns
output$myMap <- renderLeaflet({
leaflet() %>%
addTiles() %>%
setView(lng = -114.37, lat = 43.11, zoom = 6)
})
}
##### standard UI and server functions ####
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
fluidRow(
extra_UI(id = "map")
)
)
)
server <- function(input, output, session) {
callModule(module = extra_server, id = "map")
}
shinyApp(ui = ui, server = server)