Here we will create a map using the Leaflet package.
We will set the initial view of the map to be the city of Atlanta.
On the map we will add markers indicating the major parks of the city.
Let’s start by loading the Leaflet package
library(leaflet)
Now we will create the map, add markers for the major parks, and store the map in an object called “map”:
map <- leaflet() %>%
addTiles() %>%
addMarkers(lat = 33.786690, lng = -84.374850, popup = "Piedmont Park") %>%
addMarkers(lat = 33.767872, lng = -84.355103, popup = "Freedom Park") %>%
addMarkers(lat = 33.766254, lng = -84.337325, popup = "Candler Park") %>%
addMarkers(lat = 33.768749, lng = -84.376375, popup = "Central Park") %>%
addMarkers(lat = 33.760974, lng = -84.393356, popup = "Centennial Olympic Park") %>%
addMarkers(lat = 33.736044, lng = -84.371450, popup = "Grant Park") %>%
addMarkers(lat = 33.974366, lng = -84.582123, popup = "Kennesaw Mountain") %>%
addMarkers(lat = 33.808005, lng = -84.144646, popup = "Stone Mountain") %>%
addMarkers(lat = 34.151491, lng = -84.061455, popup = "Lake Lanier") %>%
setView(lat = 33.7677129, lng = -84.4206039, zoom = 10)
Now we call the object “map” to display the map that we created:
map
Feel free to zoom in or out, and click on the markers to see which park they indicate!