I was wondering if it was possible to change the single marker type (blue pins of cluster size 1) in a clustered leaflet map like the one below. The map plots the first 50 points of the quakes dataset.
library(dplyr)
library(leaflet)
data(quakes)
leaflet(data = quakes[1:50,]) %>% addTiles() %>%
addMarkers(clusterOptions = markerClusterOptions())
I was hoping to change it to something similar to the smaller clusters in green but just with 1 as the number in the center like this:
I have looked at a few solutions which involve custom JS (eg. Leaflet for R: How to change default CSS cluster classes ) however, they are focused on changing the cluster colors which I would like to keep the same as default. There was also this answer https://stackoverflow.com/a/34772451/26580697 however, I am unsure of how to implement the singleMarkerMode
value in the R leaflet package.
You can set the singleMarkerMode
option to TRUE
:
library(leaflet)
data(quakes)
leaflet(data = quakes[1:50,]) |>
addTiles() |>
addMarkers(clusterOptions = markerClusterOptions(singleMarkerMode = TRUE))