Developing Data Products: Week 2 Assignment

This simple example demosntrates how to create a web page that contains an interactive map in it using R Markdown and Leaflet.

Since the only criteria for the content of the web page is to have an interactive map created using Leaflet, I decided to include a map of Mexico (the country where I am from), showing some of the must places to visit. The markers include a popup with the name of each place.

Map with nice places to visit in Mexico

Code

The code to recreate the map can be found below.

library(leaflet)
Latitude=c(21.1619, 19.4326, 16.8531,22.8905, 20.6597, 20.4230, 20.2114, 19.6861, 17.4848, 
           20.6843, 16.7370)
Longitude=c(-86.8515, -99.1332, -99.8237, -109.9167, -103.3496, -86.9223, -87.4654, -98.8716, 
            -92.0459, -88.5678, -92.6376)
popup=c("Cancun", "Mexico City", "Acapulco", "Los Cabos", "Guadalajara", "Cozumel", "Tulum", 
        "Teotihuacan", "Palenque", "Chichen Itza", "San Cristobal de las Casas")
coordinates<-data.frame(Latitude=Latitude, Longitude=Longitude, popup=popup)
my_map <- coordinates%>%leaflet() %>%
     addTiles() %>%
     addMarkers(lat=~Latitude, lng=~Longitude, popup = ~popup, 
                clusterOptions = markerClusterOptions())

my_map