Background

Create a web page using R Markdown that features a map created with Leaflet. Host your webpage on either GitHub Pages, RPubs, or NeoCities. Your webpage must contain the date that you created the document, and it must contain a map created with Leaflet. We would love to see you show off your creativity!

Loading library and data prepare

Five of the most famous places in the city of Volgograd.

library(leaflet)

Create map

lats<-c(48.742324, 48.734400, 48.716020, 48.714424, 48.707998)

longs<-c(44.537117, 44.548543, 44.531479, 44.524508, 44.515649)

places<-c('Mamayev Kurgan', 'Volgograd Arena', 
          "Pavlov's House",
          'Planetarium',
          'The Square of Fallen Fighters')

df<-data.frame(lat=lats, lng=longs, places=places, 
               statecolor=c("blue","red","green","yellow", "purple") )

df %>%
        leaflet()%>%
        addTiles()%>%
        addCircleMarkers(color=df$statecolor, popup = df$places) %>% 
        addLegend(labels = places, colors=df$statecolor) %>%
        addPopups(df$lng, df$lat, df$places) %>%
        addProviderTiles(providers$OpenStreetMap)

Adding Many Markers

set.seed(1)
df <- data.frame(lat = runif(50, min = 48.7, max = 48.8),
                 lng = runif(50, min = 44.4, max = 44.6))
df %>% 
        leaflet() %>%
        addTiles() %>%
        addMarkers()

Making Custom Markers

set.seed(1)
df <- data.frame(lat = runif(50, min = 48.7, max = 48.8),
                 lng = runif(50, min = 44.4, max = 44.6))
df %>% 
        leaflet() %>%
        addTiles() %>%
        addMarkers(clusterOptions = markerClusterOptions())