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

NA values are repeatedly added in linked legend when switching layer off/on #456

Closed
tim-salabim opened this issue Aug 27, 2017 · 0 comments

Comments

@tim-salabim
Copy link
Contributor

tim-salabim commented Aug 27, 2017

First of all many thanks for the grouped layer/legend feature. This really is a game changer as it makes interacting with the map much cleaner. I found a little bug related to NA value rendering in the legend.

If we use the new group argument in addLegend and the data has NAs I see that the na.color part of the legend gets repeatedly added to the legend as the layer is switched on/off.

library(leaflet)
library(mapview)
library(sf)

breweries = st_join(breweries, franconia[, "district"])

pal = colorFactor(c("red", "purple", "blue"), 
                  domain = mapview::breweries$district, 
                  na.color = "#BEBEBE")

leaflet() %>%
  addTiles() %>%
  addCircleMarkers(data = breweries, color = ~pal(district), group = "breweries")  %>%
  addLayersControl(overlayGroups = "breweries") %>%
  addLegend(pal = pal, values = breweries$district, group = "breweries")

In the primary rendering of the legend everything looks as expected. If we switch the breweries layer off and on we get a second NA entry in the legend. This is repeatedly added every time we switch the layer off/on.

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