Leaflet Assignment
library(jsonlite)
## Warning: package 'jsonlite' was built under R version 3.4.4
library(leaflet)
## Warning: package 'leaflet' was built under R version 3.4.4
data <- fromJSON("https://data.cityofnewyork.us/resource/43hw-uvdj.json", flatten = TRUE)
artLatLong <- data.frame(
lat = unlist(lapply(data$the_geom.coordinates, `[[`, 2)),
lng = unlist(lapply(data$the_geom.coordinates, `[[`, 1))
)
artIcons <- makeIcon(
iconUrl = "https://people.ucsc.edu/~admcnich/images/pin.svg",
iconWidth = 35*215/230, iconHeight = 35,
iconAnchorX = 35*215/230/2, iconAnchorY = 35
)
artSites <- paste("<a href='", data$url, "'>",data$name,"</a>" ,sep = "")
artLatLong %>% leaflet() %>% addTiles() %>%
addMarkers(icon=artIcons, popup = artSites)