如何基于selectInput添加多个输出(地图+文本)

时间:2019-05-13 18:53:44

标签: r shinydashboard

如果我的selectInput选择为“ 2017”,我试图在该地图下添加一个传单地图和一个文本。我尝试了taglist(),renderUI()和renderLeaflet()添加地图和文本,但是代码不起作用。

我可以使用renderLeaflet()单独显示地图,但是当我想在地图下添加文本时,它将不再起作用。

ui.r
selectInput("class", label = "Choose a Class",
    choices = c("All Classes",
        "Class of 2017" = "2017",
        "Class of 2018" = "2018",
        "Class of 2019" = "2019"
    ))
uiOutput("mymap", height = 800)

server.r
output$mymap < -renderUI({
    if (input$class == 2017) {
        leaflet(data = data) % > % addTiles() % > %
            addMarkers(~Longitude, ~Latitude, popup = ~paste("Location", Institution, "<br>", "City: ", City, State))
        HTML(paste("Note: 1 Student represents Hawaii"))
    }
})

0 个答案:

没有答案