I am attempting to add markers to a map based on coordinates uploaded by a user. I am having trouble storing the file input as a data frame and then passing the coordinates from the data frame to the proxy map to add markers.
ui <- fluidPage(
titlePanel(title = "My Dashboard"),
sidebarLayout(
fileInput(inputId = "file",
label = "File upload"),
mainPanel(
leafletOutput("mymap")
)
)
)
server <- function(input, output) {
m <- leaflet() %>%
setView(lng = -71.0589,
lat = 42.3601,
zoom = 12) %>%
addProviderTiles(providers$CartoDB.Positron)
output$mymap <- renderLeaflet(m)
observe({
input$file
df <- read.csv('input$file$datapath')
proxy <- leafletProxy("mymap", data = df)
proxy %>% addMarkers(~long, ~lat)
})
shinyApp(ui = ui, server = server)
df <- read.csv('input$file$datapath')todf <- read.csv(input$file$datapath)for starter