Tourists from all around the country come to see Texas’s well-known teams such as the Houston Rockets, Dallas Cowboys, and San Antonio Spurs. Using the Leaflet package we can make a map of where these Texas teams call home.
# load leaflet package and data with latitude and longitude coordinates.
library(leaflet)
Texas_StadiumLatLong <- data.frame(
lat = c(29.750830255662535,32.74748290094099,29.42711658272682),
lng = c(-95.36186983060796,-97.09447244445296,-98.43744864364756))
With the makeIcon function you’re able to customize an icon that helps find the specified locations.This is especially helpful if there are multiple locations presented.
StadiumIcon <- makeIcon(
iconUrl = "https://upload.wikimedia.org/wikipedia/commons/9/9d/Webdings_x0053.png",
iconWidth = 31*215/230, iconHeight = 31,
iconAnchorX = 31*215/230/2, iconAnchorY = 16
)
Below is the final map showcasing the stadiums.Links are provided to the stadiums’ websites. Also, with the addProviderTiles function you’re able to change the theme of the map.
Team_StadiumSites<-c("<a href='https://www.toyotacenter.com/events/detail/houston-rockets-vs-los-angeles-clippers-3'>Toyota Center</a>",
"<a href='https://attstadium.com/'>AT&T Stadium</a>",
"<a href='http://www.attcenter.com/connect/sse'>AT&T Center</a>")
Texas_StadiumLatLong %>%
leaflet(width="100%", height=350) %>%
addTiles() %>%
addMarkers(~lng, ~lat,icon= StadiumIcon, popup = Team_StadiumSites)%>%
addProviderTiles(providers$Stamen.TonerLabels) %>% addProviderTiles(providers$USGS.USImageryTopo)
Using the coordinates above, the Leaflet package was able to display maps for each unique stadium. These maps help tourists and locals alike familiarize themselves with their favorite teams’ stadium locations. In addition, the website links provide easy access to purchasing tickets and looking for events to attend.