##File: Shiny2---MappingwithLeaflet
library(shiny)
library(leaflet)
r_colors <- rgb(t(col2rgb(colors()) / 255))
names(r_colors) <- colors()
ui <- fluidPage(
leafletOutput("mymap"),
p(),
#inputId and label
actionButton("recalc", "New Points")
)
server <- function(input, output, session) {
points <- eventReactive(input$recalc, {
cbind(rnorm(5) * 2 + 20, rnorm(5) + -33) #switch 13 to 10 and 48 to 45 | 20 & -33 for cape town/South Africa
}, ignoreNULL = FALSE)
output$mymap <- renderLeaflet({
leaflet() %>%
addProviderTiles(providers$Stamen.TonerLite,
options = providerTileOptions(noWrap = TRUE)
) %>%
addMarkers(data = points())
})
}
shinyApp(ui, server)
## PhantomJS not found. You can install it with webshot::install_phantomjs(). If it is installed, please make sure the phantomjs executable can be found via the PATH variable.
Shiny applications not supported in static R Markdown documents
#Q&A
##In which code where it actually display my map? I didn't input any map! "leafletOutput"
###