我正在尝试在mainPanel中创建一个地图,并在sidebarPanel中创建两个按钮。我有两个地图,我希望它们在按下特定按钮后出现在mainPanel中。
这些地图在闪亮的外部起作用。
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
actionButton("do2", "unemployed women"),
actionButton("do3", "unemployed men")
),
mainPanel(
leafletOutput("mymap2"),
leafletOutput("mymap3")
)
)
)
# Define the server logic
server <- function(input, output) {
observeEvent(input$do2, {
output$mymap2 <- renderLeaflet({
tm <- tm_shape(woj_shp) +
tm_fill(col = "unemployed_women", title = "unemployed women", palette =
"-GnBu") +
tm_borders()+
tm_layout(inner.margins=c(.15,.13, .05, .05))+
tm_text("unemployed_women", col="black", palette="Dark2")
tmap_leaflet(tm)
})
}
)
observeEvent(input$do3, {
output$mymap3 <- renderLeaflet({
tm2 <- tm_shape(woj_shp) +
tm_fill(col = "unemployed_men", title = "unemployed men", palette = "-
GnBu") +
tm_borders()+
tm_layout(inner.margins=c(.15,.13, .05, .05))+
tm_text("unemployed_men", col="black", palette="Dark2")
tmap_leaflet(tm2)
})
}
)
}
shinyApp(ui = ui,服务器=服务器)
I have this error: object 'leaflet_html' not found