Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layer control fails when using clusterOptions #889

Open
gtalavera opened this issue Nov 2, 2023 · 0 comments
Open

Layer control fails when using clusterOptions #889

gtalavera opened this issue Nov 2, 2023 · 0 comments

Comments

@gtalavera
Copy link

I am building a map that shows several markers that I want to be able to switch on/off according to a value, and at the same time I want to cluster markers that are close to each other. Layer control works fine without clustering, but once clusterOptions is activated, layer control stops working. No answers yet on my question in SO

In my reprex (using quakes), this works fine:

library(leaflet)
mini_quakes <- head(quakes, 10)
mini_quakes$stations <- as.character(mini_quakes$stations)
leaflet(mini_quakes) %>% 
  addTiles() %>% 
  addMarkers(
    group = ~stations #, 
    # clusterOptions = markerClusterOptions()
    ) %>% 
  addLayersControl(overlayGroups = mini_quakes$stations)

However, activating clusterOptions prevents layers control to work adequately.

I guess it might be solved by using addMarkers for each group, but that might be cumbersome.

Is it possible to have addLayersControl and clusterOptions working together?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant