传单反应不正常(闪亮)

时间:2019-05-05 05:34:03

标签: r shiny leaflet shiny-reactivity shinyapps

为什么我的传单地图不响应我的UI下拉列表和滑块? 我可以加载地图和侧边栏+滑块,但它们不是交互式的-_- 我是否在服务器中正确指定了反应性感到困惑?

xxxxxxxxxxalalalalalalalalalalalalalalalalalalalalalalalal

GLOBAL

library(shiny)

library(shinythemes)

library(leaflet)

library(RColorBrewer)

library(formattable)

library(dplyr)

加载数据集

murals <- read.csv("https://data.cityofchicago.org/api/views/we8h-apcf/rows.csv?accessType=DOWNLOAD",
               stringsAsFactors = F)



circle.scaler <- function(x){((x-min(x))/(max(x)-min(x)))*500}

UI

ui <- bootstrapPage(
tags$style(type = "text/css", "html, body {width:100%;height:100%}"),
leafletOutput("mymap", width = "100%", height = "100%"),
absolutePanel(top = 10, right = 10,


              theme = shinytheme("lumen"),

              titlePanel("Chicago Neighborhood Murals"),

              selectInput("Artist.Credit", 
                          label = "Artist",
                          choices = c("All",
                                      unique(as.character(murals$Artist.Credit))),
                          selected = "Renee Robins"),

              selectInput("Artwork.Title", 
                          label = "Title",
                          choices = c("All",
                                      unique(as.character(murals$Artwork.Title))),
                          selected = "Kaleidoscope of Hidden Worlds"),

              sliderInput("Year.Installed", "Year Installed", min(murals$Year.Installed),   
                          max(murals$Year.Installed), value = range(murals$Year.Installed),sep =""),
              uiOutput("YearSlider")))

服务器

server <- function(input, output, session) {




 filteredData <- reactive({
    req(input$Year.Installed)
    req(input$Artist.Credit)
    req(input$Artwork.Title)
    murals[murals$Year.Installed <= input$yearslideroutput[1]
        & murals$Year.Installed >= input$yearslideroutput[2]
        & murals$Artist.Credit == input$Artist.Credit
        & murals$Artwork.Title == input$Artwork.Title,]

})

output$mymap <- renderLeaflet({
        leaflet(murals) %>%
        addTiles() %>%
        addCircleMarkers(lng = ~Longitude,
                         lat = ~Latitude,
                         popup = paste("Artist:", input$Artist.Credit, "<br>",
                                       "Medium:", murals$Media, "<br>",
                                       "Location Description:", murals$Location.Description, "<br>",
                                       "Ward:", murals$Wards, "<br>",
                                       "Year:", murals$Year.Installed, "<br>",
                                       "Year Restored:", murals$Year.Restored))

}) }

0 个答案:

没有答案