In this assignment, we have to produce an interactable map using the Leaflet package in R, and publish it on either GitHub, RPubs or NeoCities.
library(jsonlite)
## Warning: package 'jsonlite' was built under R version 4.2.3
library(leaflet)
## Warning: package 'leaflet' was built under R version 4.2.3
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://www.svgrepo.com/show/532540/location-pin-alt-1.svg",
iconWidth = 35*215/230, iconHeight = 35,
iconAnchorX = 35*215/230/2, iconAnchorY = 35
)
artSites <- paste("<a href='", data$url, "'>",data$name,"</a>" ,sep = "")
date = format(Sys.Date(),format="%d-%B-%Y")
18-October-2023
artLatLong %>% leaflet() %>% addTiles() %>%
addMarkers(icon=artIcons, popup = artSites)