Hi, I have trouble working with R Shiny & Leaflet, by any chance does anyone know? I would like some help.
Thank you!
Hi, I have trouble working with R Shiny & Leaflet, by any chance does anyone know? I would like some help.
Thank you!
Hi @lauratangwt,
Please re-phrase your question in a more specific way. What issues exactly do you have with R Shiny and Leaflet? So it will be easier for people here to help you.
Hello, so currently i have issues with connecting the UI to the server for numericInput and selectInput. I would greatly appreciate if someone could help me!
library(shiny)
library(leaflet)
library(dplyr)
library(magrittr)
# Define user interface (UI)
ui <- fluidPage(
titlePanel("Where do you want to go today?"),
numericInput("longitude", "Enter a longitude",
value = 174.8, min = -180, max = 180, step = 0.1),
numericInput("latitude", "Enter a latitude",
value = -36.9, min = -90, max = 90, step = 0.05),
sliderInput("zoom_level", "Enter a zoom level",
min = 3, max = 18, value = 11, step=1),
selectInput("basemap","Select a basemap",
choices = c("Esri.WorldImagery", "Stamen.Terrain", "OpenTopoMap", "Stamen.Watercolor"),selected = "Esri.WorldImagery"),
leafletOutput("m")
)
# Define server logic
server <- function(input, output, session) {
filtered_data<-reactive({
filtered_data%>%
filter(base_map %in% input$basemap)
})
output$m <- renderLeaflet({
leaflet(data=filtered_data()) %>%
addTiles() %>% setView(31.13767, 29.97515, zoom = 7)%>% addProviderTiles(provider = "Esri.WorldImagery")
})
}
shinyApp(ui, server) # Run app