This web page features a map created with the leaflet
package in R. The map below showcases the New 7 Wonders of the
World, highlighting their geographical locations with
interactive markers.
Feel free to zoom in, pan around, and click on the markers to see the name of each wonder!
# Load the leaflet library
library(leaflet)
# Create a data frame containing the wonders, their coordinates, and popup descriptions
wonders <- data.frame(
name = c("Great Wall of China", "Petra", "Colosseum",
"Chichen Itza", "Machu Picchu", "Taj Mahal", "Christ the Redeemer"),
lat = c(40.4319, 30.3285, 41.8902, 20.6843, -13.1631, 27.1751, -22.9519),
lng = c(116.5704, 35.4444, 12.4922, -88.5678, -72.5450, 78.0421, -43.2105),
description = c(
"<b>Great Wall of China</b><br>China",
"<b>Petra</b><br>Ma'an, Jordan",
"<b>Colosseum</b><br>Rome, Italy",
"<b>Chichen Itza</b><br>Yucatán, Mexico",
"<b>Machu Picchu</b><br>Cuzco Region, Peru",
"<b>Taj Mahal</b><br>Agra, Uttar Pradesh, India",
"<b>Christ the Redeemer</b><br>Rio de Janeiro, Brazil"
)
)
# Generate the leaflet map
my_map <- leaflet(wonders) %>%
addTiles() %>% # Add default OpenStreetMap map tiles
addMarkers(
lat = ~lat,
lng = ~lng,
popup = ~description,
clusterOptions = markerClusterOptions() # Groups markers when zoomed out
)
# Display the map
my_map
To host this on GitHub Pages: 1. Render this document to HTML in
RStudio by clicking the Knit button. 2. Ensure the
output file is named index.html. 3. Create a new GitHub
repository, upload both index.Rmd and
index.html. 4. Go to the repository
Settings -> Pages and enable GitHub
Pages from the main branch.