Interactive Map Assignment

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!

Submission

I wanted to see an interactive map of all of the theatres in NYC. I got this data from the OpenData NYC API.

##Open json data file
library(jsonlite)
library(leaflet)
data <- fromJSON("https://data.cityofnewyork.us/resource/2hzz-95k8.json", flatten = TRUE)

##Set Lat Long

TheatreLatLong <- data.frame(
  lat = unlist(lapply(data$the_geom.coordinates, `[[`, 2)),
  lng = unlist(lapply(data$the_geom.coordinates, `[[`, 1))
)

##Set icons to show locations

TheatreIcons <- makeIcon(
  iconUrl = "https://people.ucsc.edu/~admcnich/images/pin.svg",
  iconWidth = 35*215/230, iconHeight = 35,
  iconAnchorX = 35*215/230/2, iconAnchorY = 35
)

TheatreSites <- paste("<a href='", data$url, "'>",data$name,"</a>" ,sep = "")

Theatre Map of New York, NY

01/20/2017

Start spreading the news. I’m leaving today…

TheatreLatLong %>% leaflet() %>% addTiles() %>%
addMarkers(icon=TheatreIcons, popup = TheatreSites)