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

Add control on min and max size of symbols #88

Open
sylvaine31 opened this issue May 28, 2024 · 2 comments
Open

Add control on min and max size of symbols #88

sylvaine31 opened this issue May 28, 2024 · 2 comments

Comments

@sylvaine31
Copy link

sylvaine31 commented May 28, 2024

Hello,
I don't know if it's possible (or easy), but it would be nice to have more control over the legend size. For example, instead of just the "baseSize" argument, having "minSize" and "maxSize" arguments would be great.

@tomroh
Copy link
Owner

tomroh commented May 30, 2024

@sylvaine31, this is a significant departure from the way it is currently setup. How does the current implementation not meet your expectations? You do have control over setting min and max size just not directly. You could pass a vector of min/max instead of directly using your data and adjust baseSize and breaks to get an approximation of your desired min/max.

@sylvaine31
Copy link
Author

Hello,
Thanks for your quick answer.
I think I misused the package. In the example below, I can't achieve to see the 3 points with a decent size for the bigger one :

ploup <- tibble::tribble(
  ~value, ~lat, ~long, 
  1,1.2, 43,
  50,1.3, 42.5,
  143,1.25, 43.5) %>% 
  sf::st_as_sf(coords = c("lat", "long")) %>% 
  sf::st_set_crs(4326)

# création des tailles de symboles

basesize = 20
symbols <- leaflegend::makeSymbolsSize(
  values = ploup$value,
  shape = 'circle',
  color = 'red',
  fillColor = 'red',
  opacity = .5,
  baseSize =basesize
)

# Carte
 library(leaflet)
  leaflet() %>% 
  addProviderTiles("CartoDB.Positron", group = "CartoDB.Positron") %>%
  addMarkers(data = ploup,
             icon = symbols)%>%
  leaflegend::addLegendSize(
    values = ploup$value,
    position = "topright",
    color = 'red',
    fillColor = 'red',
    opacity = .5,
    baseSize = basesize,
    shape = 'circle',
    orientation = 'vertical',
    breaks = 5,
    stacked = FALSE)

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

2 participants