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

extend the fillOpacity option in the function addGeoJSONChoropleth() #53

Open
TrantorM opened this issue Jan 19, 2017 · 7 comments
Open
Assignees

Comments

@TrantorM
Copy link

Hi @bhaskarvk
Thank you very much for this wonderful package. You did a great job.

The option fillOpacity in the functionaddGeoJSONChoropleth() seems to work just with a constant value (e.g. fillOpacity = 0.7). Would it be possible to extend it, that it can handle also feature properties in the same way like the valueProperty can do? In this was, one could weight the opacity of the polygons e.g. according to the significance of the data. In the example below I want to control the opacity with the dist_num property, which is meaningless but it shows what I want to do.

library(leaflet)
library(leaflet.extras)   
topojson <- readr::read_file("https://rawgit.com/TrantorM/leaflet-choropleth/gh-pages/examples/basic_topo/crimes_by_district.topojson")

leaflet() %>% 
  setView(-75.14, 40, zoom = 11) %>%
  addProviderTiles("CartoDB.Positron") %>% 
  addGeoJSONChoropleth(
    topojson,
    valueProperty ='incidents',
    fillOpacity = JS("function(feature){return (feature.properties.dist_num / 100);}")
  )
@bhaskarvk
Copy link
Contributor

Yes it is certainly possible to do this. I will add it to my list.

@TrantorM
Copy link
Author

Thank you very much.

@bhaskarvk bhaskarvk self-assigned this Jan 19, 2017
@TrantorM
Copy link
Author

TrantorM commented Aug 4, 2017

Hi @bhaskarvk

I saw that your are working again on the great leaflet.extra package. Is this issue still on your work list?

@bhaskarvk
Copy link
Contributor

Yup, I hope to close out most issues in next 1 to 2 month period.

TrantorM added a commit to TrantorM/leaflet.extras that referenced this issue Sep 12, 2017
…according issue trafficonese#53

fillOpacity can now be set with a property value
@trafficonese
Copy link
Owner

@TrantorM do you have a working solution for this?
If yes, could you please open a PR?
I would be happy to merge it!

@TrantorM
Copy link
Author

@trafficonese sorry, I'm not working on this anymore.

@trafficonese
Copy link
Owner

Ok, but you're fork seems to work with different fillOpacities or am I wrong?

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

No branches or pull requests

3 participants