The instructions for this project are pretty generic: Create a web page using R Markdown that features a map created with Leaflet.
What you’re reading here is that R markdown report. What follows below is a leaflet rendering of select American national parks in the Southwestern region.
We will load the leaflet library in a separate code chunk should any library messages occur.
library(leaflet)
The latitude and longitude coordinates for the selected parks were taken from Google Maps.
ZION <- c(37.207619258835095, -112.99020052788188)
Bryce <- c(37.60623860320969, -112.18619231986729)
Arches <- c(38.741665902899555, -109.57360269319129)
GrandCanyon <- c(36.10261091022293, -112.11289243145738)
parkLocations <- data.frame(lat=c(ZION[1],Bryce[1],Arches[1],GrandCanyon[1]),
lng=c(ZION[2],Bryce[2],Arches[2],GrandCanyon[2]))
parkNames <- c("ZION National Park",
"Bryce Canyon National Park",
"Arches National Park",
"Grand Canyon National Park")
parkIcon <- makeIcon(iconUrl = "Tree.png", iconWidth = 31*215/230, iconHeight = 31,
iconAnchorX = 31*215/230/2, iconAnchorY = 16)
leaflet(parkLocations) %>% addTiles() %>% addMarkers(popup = parkNames, icon = parkIcon) -> map; map
Click on a tree icon to see which national park it represents.