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!
The rubric contains the following two questions:
I’ve created an interactive map that shows the area around China University of Petroleum (Huadong), which includes the university icon and popup website, the shopping/hotel/restaurant/entertainment options in different colors, and the legend on the map.
library(leaflet)
## Create the university icon
UPCicon<-makeIcon(
iconUrl = "http://2015www.upc.edu.cn/_upload/tpl/00/15/21/template21/images/logo_long20150923.jpg",
iconWidth = 418/4, iconHeight = 92/4,
iconAnchorX = 418/4/2, iconAnchorY = 92/4/2)
## Add the university website link
UPCsite<-"<a href='http://www.upc.edu.cn'>China University of Petroleum (Huadong)</a>"
## Add the latitudes and longitudes of the shopping/hotel/restaurant/entertainment options
shopping<-data.frame(lat=c(35.9336,35.95413,35.95204,35.95468,35.95532), lng=c(120.1674,120.18495,120.18089,120.18096,120.18347), name=c("Rio Outlet","Mykal Shopping Center","Jiajiayuan Supermarket","Grand Centry Shopping Center","Aeon Shopping Center"), col=replicate(5, "darkorange"))
hotel<-data.frame(lat=c(35.9467,35.94773), lng=c(120.1684,120.17349), name=c("Howard Johnson Grand Hotel","Blue Horizon Grand Hotel"), col=replicate(2, "purple"))
restaurant<-data.frame(lat=c(35.9476,35.9468,35.9479), lng=c(120.1691,120.1695,120.1707), name=c("Shujiuxian Szechuan Restaurant","Chuanxiangfu Szhechuan Restaurant","Feixiang Seafood Restaurant"), col=replicate(3, "red"))
entertainment<-data.frame(lat=c(35.9309,35.9351,35.94329), lng=c(120.1650,120.1703,120.18473), name=c("Rio Theme Park","Sky Wheel","Haiyun Marine Park"), col=replicate(3, "blue"))
## Add the custom icon, circle markers and legend to the map in different colors
my_map<-leaflet() %>%
addTiles() %>%
addMarkers(lat = 35.940562, lng = 120.170921, icon = UPCicon, popup = UPCsite) %>%
addCircleMarkers(data = shopping, popup = shopping$name, color = shopping$col, radius = 6, stroke = FALSE, fillOpacity = 0.6, group = "shopping") %>%
addCircleMarkers(data = hotel, popup = hotel$name,color = hotel$col, radius = 6, stroke = FALSE, fillOpacity = 0.6, group = "hotel") %>%
addCircleMarkers(data = restaurant, popup = restaurant$name,color = restaurant$col, radius = 6, stroke = FALSE, fillOpacity = 0.6, group = "restaurant") %>%
addCircleMarkers(data = entertainment, popup = entertainment$name,color = entertainment$col, radius = 6, stroke = FALSE, fillOpacity = 0.6, group = "entertainment") %>%
addLegend(labels = c("shopping","hotel","restaurant","entertainment"), colors = c("darkorange","purple","red","blue"))
my_map