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

Hide Layer on Zoom threshold #2192

Closed
nikit91 opened this issue Aug 15, 2018 · 4 comments
Closed

Hide Layer on Zoom threshold #2192

nikit91 opened this issue Aug 15, 2018 · 4 comments

Comments

@nikit91
Copy link

nikit91 commented Aug 15, 2018

Hello,

I am quite new at deck.gl and I have been trying to implement something using DeckGL standalone.
I have implemented a hexagon layer on my data. However, I realized that my data is spread across many countries on the map and I would like to have an extra icon layer to point the user where exactly could they zoom in to find the hexagonal bars.

I implemented the icon layer, but then after zooming in the map looks something like this:

examplemap

As you can probably notice, the icon stays in the background.

What I would like to know is if somehow I could change the visibility of a layer based on the value of zoom.

@SinZ163
Copy link

SinZ163 commented Aug 21, 2018

The way I handle it for IconLayer's is a dynamic getSize that returns 0 if viewstate.zoom > 10 or whatever zoom level makes sense for you. For other layers I use opacity.

The intended way however is visible prop on the layer, which can just be an expression doing a comparison on viewstate.zoom

@nikit91
Copy link
Author

nikit91 commented Aug 21, 2018

Hi @SinZ163 ,

Thanks for your response.
I understood what you said, but somehow I am not able to figure out how do I access that variable viewstate inside the getSize method. The only thing I am able to access is the related data.

@snosenzo
Copy link

snosenzo commented Sep 7, 2018

Try figuring out how to access the viewport in the base map component, and passing it as props down to deckgl for logic in the visible prop for the layer. It should be something like viewport.zoom in the base map. Check out the vis academy tutorials to find out about how the viewport is read in and changes; I don't have much experience with OpenStreetMap, but there should be functionality in it to get the zoom level.

@1chandu
Copy link
Contributor

1chandu commented Nov 1, 2018

@nikit91, you can listen to onViewStateChange callback prop and update your layer list based on zoom value.

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

5 participants