1

I am mapping boardings at transit stops as circle markers using radius = ~Ons to create a continuous graduated symbols map. I am wondering if there is a way to make a legend in Leaflet for R where the size of the circles in the legend correspond with the level of boardings. Do I need to impose some bins to make this work? Most of the examples I have found are about choropleth maps, but I want the color of the symbols to remain unchanged.

I tried to follow example 1.7 from this page but I get an error message:

argument "colors" is missing with no default.

I tried adding pal = "#55cc00", but then I get the following error message:

no applicable method for 'metaData' applied to an object of class "NULL".

I also looked at this post but it doesn't seem to transfer entirely because the data is categorical.

Does anyone know how to do this? Thanks for the help

ridership_25<- leaflet()%>%
  setView(-75.1213, lat = 39.97266, zoom = 12)%>%
  addProviderTiles(providers$Wikimedia)%>%
  addPolylines(data = line_25, 
               color = 'tomato', 
               weight = 1.5)%>%
  addCircleMarkers(data = the_25, 
             color = 'tomato', 
             radius = ~Ons, 
             fillOpacity = 0.4, 
             popup = paste("Route: ", the_25$LineAbbr, "<br>",
                           "Direction: ", the_25$Direction, "<br>",
                            "Boards: ", the_25$Ons, "<br>",
                           "Alights: ", the_25$Offs))%>%
  addLegend("bottomright", values = ~Ons, title = "Boardings, opacity = 0.6")

ridership_25

Would it be helpful if I showed some of the the_25 dataset? Not sure the best way to do that with an sf object.

lovalery
  • 4,524
  • 3
  • 14
  • 28
popcorn
  • 31
  • 3

0 Answers0