I would like to add border to the CircleMarkers. I used the following code. I can't find any function to add black border to the stroke.
pal <- colorNumeric(palette = 'RdYlBu', domain = city_results$ratio)
m <- leaflet() %>%
addTiles() %>%
setView(lng = median(city_results$long),
lat = median(mean(city_results$lat)),
zoom = 8) %>%
addProviderTiles(providers$CartoDB) %>%
addCircleMarkers(data = city_results, lng = ~long, lat = ~lat,
radius = ~(Socioeconomic_status_group),
color = ~pal(ratio),
stroke = TRUE, fillOpacity = 0,
popup = ~as.character(nameH),
label = ~as.character(round(corr_value,2)),
labelOptions = labelOptions(noHide = T, textOnly = TRUE))
If you mean that you want to use black color for stroke, the following code does the job. I used the earthquakes data from the leaflet package for this demonstration. You want to use fillColor
to fill markers and save color
to assign a color to strokes.
library(leaflet)
pal <- colorNumeric(palette = "Blues", domain = quakes$mag)
leaflet() %>%
addProviderTiles("OpenStreetMap.Mapnik") %>%
addCircleMarkers(data = quakes,
radius = ~mag * 5,
color = "black",
fillColor = ~pal(mag),
stroke = TRUE, fillOpacity = 0.5)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With