Everything is great, except I can't get a second dropdown selectInput to show up on my leaflet map -- what's the problem??? I want to add a Title drop down (variable: Artwork.Title).
Also, the only thing showing up on my popups are the artist name -- why?
Here's my working app: https://bokun001.shinyapps.io/project/
library(shiny)
library(shinythemes)
library(shinydashboard)
library(shinyjs)
library(leaflet)
library(tidyverse)
## load data ##
murals <- read.csv("https://data.cityofchicago.org/api/views/we8h-apcf/rows.csv?accessType=DOWNLOAD",
stringsAsFactors = F) %>%
filter(!is.na(Latitude) & !is.na(Longitude))
## clean data ##
# clean Media type
murals$Media <- str_replace(murals$Media, "spray", "Spray")
murals$Media <- str_replace(murals$Media, "Spray + brush", "Spray and Brush")
murals$Media <- str_replace(murals$Media, "Painting", "Paint")
murals$Media <- str_replace(murals$Media, "Mosaic Tiles", "Mosaic")
# clean Titles
murals$Artwork.Title <- str_replace(murals$Artwork.Title, "Where There Is Discord, Harmony:The Power of Art", "Where There Is Discord, Harmony: The Power of Art")
murals$Media <- str_replace(murals$Media, "LAKE VIEW", "Lake View")
############### 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"),
shinyjs::inlineCSS(list(body = "color:White")),
titlePanel("Chicago Neighborhood Murals"),
selectInput(inputId = "Artist.Credit",
label = "Artist",
choices = c(murals$Artist.Credit),
selected = "Johanna Poethig"),
p("Data Source: City of Chicago Data Portal", a("Mural Registry", href = "https://data.cityofchicago.org/Historic-Preservation/Mural-Registry/we8h-apcf")),
p("Updated May 4, 2019"),
p("Code can be found on github", a("repository.", href = "https://github.umn.edu/BOKUN001/Murals")),
p("Built with",
img(src = "https://www.rstudio.com/wp-content/uploads/2014/04/shiny.png", height = "30px"),
"by",
img(src = "https://www.rstudio.com/wp-content/uploads/2014/07/RStudio-Logo-Blue-Gray.png", height = "30px"),
".")
))
############### server ##################
server <- function(input, output, session) {
filtered <- reactive({
require(input$Artist.Credit) # ensure availablity of value before proceeding
murals[murals$Artist.Credit == input$Artist.Credit, ]
})
output$mymap <- renderLeaflet({
murals <- data()
# define colors
color <- colorFactor(topo.colors(3), murals$Affiliated..or.Commissioning..Organization)
m <- leaflet(data = filtered()) %>%
addProviderTiles("Esri.WorldImagery") %>%
addCircleMarkers(lng = ~Longitude,
lat = ~Latitude,
color = ~color(Affiliated..or.Commissioning..Organization),
popup = paste("Artist:", input$Artist.Credit, "<br>",
"Address:", input$Street.Address, "<br>",
"Location Description:", input$Location.Description, "<br>",
"Ward:", input$Wards, "<br>",
"Year:", input$Year.Installed, "<br>",
"Year Restored:", input$Year.Restored))
m
}) }
shinyApp(ui, server)