How to specify radius units in addCircleMarkers() when using Leaflet in R -


i'm trying visualize shipment origin destination using leaflet map created r within shiny application.

i want add circle marker of radius corresponding odist , ddist variables come form reactive dataframe called main()

below relevant snapshot accompanying code:

pic1

output$leaflet1 <- renderleaflet({   leaflet() %>%     addcirclemarkers(data = main(), lng = main()$olong, lat = main()$olat, color = 'black', fillcolor = coygreen,                      radius = main()$odist, opacity = .5) %>%      addcirclemarkers(data = main(), lng = main()$dlong, lat = main()$dlat, color = 'black', fillcolor = coygreen,                       radius = main()$ddist, opacity = .3) }) 

for above example argument radius = main()$odist equivalent radius = 50. however, 50 units seem arbitrary (the cirlce smaller larger 1 radius = main()$ddist = 125 both circles enlarge , shrink zoom in , out). able set radius of circle marker fixed radius in miles, haven't been able figure out how so. appreciated!

if use addcircles instead of addcirclemarkers circles have constant radius (in meters). here's reproducible example using mapview uses addcirclemarkers. on top plot same locations using addcircles

library(mapview)  m <- mapview(breweries91) # uses addcirclemarkers circle radius changes zoom  m@map %>%    addcircles(data = breweries91, color = "red", radius = 100) # circle radius constant 

if zoom in see smaller red circles become bigger in relation standard blue circlemarkers used in mapview


Comments