Developing Data Products - Leaflet Assignment

Criteria

  • Create a webpage using RMarkdown.
  • Feature a date that is within two months prior to the assignment.
  • Create an interactive map using leaflet.

Objectives

  • Draw a circle 100km radius from the midpoint of NJ.
  • Add a marker to the center.
library(leaflet)

location <- c(lat = 40.0583, lng = -74.4057)  # Approximate center of New Jersey
radius <- 50000  # 50 km radius

# Create a leaflet map with the radius circle
leaflet() %>%
  addTiles() %>%  # Add map
  addCircles(lng = location['lng'], lat = location['lat'], radius = radius, 
             color = "blue", fill = TRUE, fillColor = "blue", fillOpacity = 0.2) %>%   # Add a radius circle
  addMarkers(lng = location['lng'], lat = location['lat'], popup = "Center of NJ") %>% 
  setView(lng = location['lng'], lat = location['lat'], zoom = 9)
## Input to asJSON(keep_vec_names=TRUE) is a named vector. In a future version of jsonlite, this option will not be supported, and named vectors will be translated into arrays instead of objects. If you want JSON object output, please use a named list instead. See ?toJSON.