Shounak Shastri
27-06-2020
This app places landmarks randomly on a map using leaflet
I have omitted the documentation lines since the code is too large to fit in one slide.
library(shiny)
library(dplyr)
library(leaflet)
ui <- fluidPage(
headerPanel("Create Random Landmarks"),
headerPanel(" "),# Add vertical space between two lines
sidebarPanel(# Documentation lines
numericInput("lat", "Latitude", value = 40.7128, min = -90.0000, max = 90.0000 ),
# Documentation lines
numericInput("lon", "Longitude", value = -74.0060, min = -180.0000, max = 180.0000 ),
# Documentation lines
sliderInput("rnge", "Range", value = 0.05, min = 0.00, max = 1.00),
# Documentation lines
numericInput("no_of_points", "Number of Landmarks", value = 500, min = 100, max = 1500),
actionButton("submit", "Generate Map"),
width = 3),
mainPanel(leafletOutput("map")))
Generates and displays the markers on the leaflet map
server <- function(input, output, session) {
df <- eventReactive(input$submit, { data.frame(lat = runif(input$no_of_points,
min = input$lat - input$rnge,
max = input$lat + input$rnge),
lng = runif(input$no_of_points,
min = input$lon - input$rnge,
max = input$lon + input$rnge))
})
output$map <- renderLeaflet(leaflet(data = df()) %>%
addTiles() %>%
addMarkers(clusterOptions = markerClusterOptions()))
}
https://shouankshastri.shinyapps.io/Week_4_Assignment/
https://github.com/shounakshastri/Developing-Data-Products-Assignment