Reputation: 21
I am creating a Shiny App dashboard which involves plotting a map using Latitudes and Longitudes using Leaflet in one of the tabs. I need Leaflet for Zoom and the popup option. However, the map is not rendering in the app, it doesn't throw any error and shows a grey space where the map ideally should be. There were no such issues with the R console and it rendered the map perfectly.
I found a similar issue on the link below but it is not solving my issue. Shiny/Leaflet map not rendering.
I have also tried the workaround mentioned on this link below but it is breaking my other plots. https://github.com/rstudio/shiny/issues/650
ui <- dashboardPage(
dashboardHeader(title = "Crimes Dashboard"),
dashboardSidebar(
sidebarMenu(
menuItem("Tab1", tabName = "Tab1" , icon=icon("th")),
menuItem("Tab2", tabName = "Tab2" , icon=icon("th")),
menuItem("Tab3", tabName = "Tab3" , icon=icon("th")),
menuItem("Tab4", tabName = "Tab4" , icon=icon("th"))
)
),
dashboardBody(
tabItems(
#Fourth Tab
tabItem(tabName = "Tab4",
h2("Tab4"),
leafletOutput(outputId = "mymap")
)
)
)
)
server <- function(input, output, session) {
reactive_data2 <- reactive({
crime <- crime[-which (is.na(crime$Location)),]
})
output$mymap <- renderLeaflet({
reactive_data2() %>%
mutate(popup = str_c(Date,
Block,
str_c("Location type:", `Location Description`,
sep = " "),
sep = "<br/>")) %>%
leaflet() %>%
addTiles() %>%
addMarkers(clusterOptions = markerClusterOptions(),popup = ~popup) %>%
frameWidget()
})
}
shinyApp(ui, server)
Upvotes: 1
Views: 708
Reputation: 21
I found a solution to this, removing the frameWidget() from the end solved the issue, thanks!
Upvotes: 1