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 visible attribute to GeoJSON layer #1002

Merged
merged 1 commit into from
Jun 22, 2022

Conversation

davidbrochart
Copy link
Member

Fixes #827.

@giswqs
Copy link
Contributor

giswqs commented Jun 22, 2022

Wow, this is nice! I have been waiting for this feature for a while. Thank you.

@giswqs
Copy link
Contributor

giswqs commented Jun 22, 2022

Besides the visible attribute, would it be possible to also add an opacity attribute like the TileLayer?

@davidbrochart
Copy link
Member Author

I've been trying to implement the visible attribute using opacity and fillOpacity before reaching this solution. My conclusion is that it was a mess, because there are global opacities and feature opacities, and once you set the global opacity to 0 you cannot revert.

@giswqs
Copy link
Contributor

giswqs commented Jun 22, 2022

Thanks for clarifying. It would still be nice if you can add the fillOpacity attribute. This will allow the fill opacity of polygon layers to be changed interactively.

@davidbrochart
Copy link
Member Author

Yes, but it can get quite complex because you need to handle the opacity also (polygon border, which can have a different value than fillOpacity), and the style in mouseover and mouseout can also set the opacity...
Would you like to try in a separate PR?

@giswqs
Copy link
Contributor

giswqs commented Jun 22, 2022

I would love to contribute. I really need to learn JavaScript. Once this PR is merged and the visible attribute is working, I will see if I can make the opacity attribute work.

@jasongrout
Copy link
Member

The docs test is failing for unrelated reasons (404 on a resource)

@jasongrout jasongrout merged commit 16467d2 into jupyter-widgets:master Jun 22, 2022
@davidbrochart davidbrochart deleted the geojson_visible branch June 22, 2022 20:12
@giswqs
Copy link
Contributor

giswqs commented Jul 8, 2022

I just tested v0.17.0 and the GeoJSON visible attribute. Just figured out that you can actually control the style attribute to set opacity. So it is now possible to change the GeoJSON layer opacity interactively.

g.style={'fillOpacity': 0.5, 'opacity': 1}

image

@davidbrochart
Copy link
Member Author

So this is not working since v0.17, right? I guess it was already working before.

@giswqs
Copy link
Contributor

giswqs commented Jul 8, 2022

@davidbrochart It is working well. I was just saying that the geojson layer opacity can be changed using the style attribute, so I don't need to submit a PR to mess up the JS code.

@giswqs
Copy link
Contributor

giswqs commented Jul 8, 2022

I did not know that style attribute before v0.17.0. I was working on the PR and then realized that the style attribute is exactly what I needed to change layer opacity interactively, so no PR from me.

@davidbrochart
Copy link
Member Author

Great, I just meant that this is not particularly true since v0.17, the style attribute was there before.

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

Successfully merging this pull request may close these issues.

Changing GeoJSON/GeoData layer visibility programmatically
3 participants