I have the shiny app with the leaflet map below. I would like to know if it is possible to click on a random spot of the map and create a new marker colored let's say red but in any case different from the markers that appear right mow. Then the new latitude and longitude will be displayed in table below the map. This can happen as many times an the users clicks on random spots of the map.
library(shiny)
library(leaflet)
dta<-data.frame(lat = c(40.61955, 40.61955, 40.61955, 40.61955,
40.61955, 40.61955, 40.61955, 40.6659, 40.6659, 40.6659, 40.6659,
40.6659, 40.6659, 40.6659, 40.6659, 40.6659, 40.6659, 40.6659,
40.6664, 40.6664), long = c(-74.02346, -74.02346, -74.02346,
-74.02346, -74.02346, -74.02346, -74.02346, -73.99604, -73.99604,
-73.99604, -73.99604, -73.99604, -73.99604, -73.99604, -73.99604,
-73.99604, -73.99604, -73.99604, -73.80175, -73.80175), city = c("brooklyn",
"brooklyn", "brooklyn", "brooklyn", "brooklyn", "brooklyn", "brooklyn",
"brooklyn", "brooklyn", "brooklyn", "brooklyn", "brooklyn", "brooklyn",
"brooklyn", "brooklyn", "brooklyn", "brooklyn", "brooklyn", "south ozone park",
"south ozone park"))
ui <- fluidPage(
leafletOutput("mymap")
)
server <- function(input, output, session) {
output$mymap <- renderLeaflet({
dta%>%
leaflet() %>%
addProviderTiles(providers$Stamen.TonerLite,
options = providerTileOptions(noWrap = TRUE)
) %>%
addAwesomeMarkers(
icon = awesomeIcons(
icon = "exclamation-circle",
iconColor = "#FFFFFF",
library = "fa",
markerColor = "darkblue"
))
})
}
shinyApp(ui, server)