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

Reload an image source #3037

Closed
areichman opened this issue Aug 19, 2016 · 3 comments
Closed

Reload an image source #3037

areichman opened this issue Aug 19, 2016 · 3 comments

Comments

@areichman
Copy link

I would like to add some time-based raster layers to a map (e.g. radar weather overlays). To do this in Leaflet, I've generally created a LayerGroup with a TileLayer for each timestamp I have available. Then some code (in response to either a user interaction or setInterval timer) would show/hide each layer in the group using CSS.

I'm wondering if there's a way to do this using a single source/layer in GL (version 0.21.0). Is there a set of methods that would allow something similar to GeoJSONSource#setData that would reload and redraw the layer if the image URL changed, etc.?

@lucaswoj
Copy link
Contributor

@areichman You have two options for implementing this

  1. removeSource the image source and addSource a new one with the new URL
  2. create a series of image sources and show/hide them using "visibility": false

We could theoretically add an ImageSource#setURL method but I prefer the functionally equivalent option 1. above.

@areichman
Copy link
Author

areichman commented Aug 19, 2016

@lucaswoj Option 1 is what I'm currently doing and it works well enough for my use case. It does add a bit of flicker though as the layer is removed and re-added, so I wanted to check if there were other ideas.

If the flicker becomes an issue (e.g. for weather time-lapse loops) I can go down the Option 2 path again like I have done with Leaflet in the past.

@lucaswoj
Copy link
Contributor

I wonder if the flicker could be addressed within the scope of #1989 💭

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