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
Make it so things don't flash so much when you change the tile source URL #5364
Conversation
This got me wondering if |
Nice to see this improvement @tschaub ! |
@tschaub should setUrl be used here as well then? https://github.com/openlayers/ol3/blob/master/examples/wms-time.js#L40 or am I taking your words too strictly "This means that source.setUrl() can (and should) be used for "smooth rendering" on changes" ? I guess I'm misinterpreting that sentence ;-) |
When you call |
Very nice generalisation @tschaub. To me, this looks great. Please merge. @bartvde: For WMS sources, |
Thank you @ahocevar for clarifying and sorry for the noise. |
The source's key is used as the key for all tiles in the source. For URL tile sources, the URL is the key.
Thanks for the reviews. I've added tests and upgrade notes. I'll merge when green. @bartvde - I meant that |
cool thanks for the clarification and thanks for the PR @tschaub |
In case the effect of this is not clear, here's the example in action: And the old behavior: (The second gif doesn't capture all the flashes you see even with a full cache.) |
This generalizes the work in #4389 (originally #3660) and #4527 so that all tile sources can enjoy flash-free rendering when things change. Instead of a WMTS or WMS specific property, all tile sources have a
key
that is assigned to tiles created by the source (as thetile.key
property). The WMTS source uses itsdimensions
property to generate the key (ifdimensions
change, thekey
changes). The WMS source uses itsparams
property to generate the key (ifparams
change, thekey
changes). The URL sources (e.g.ol.source.XYZ
) use theurl
property to generate the key.As a result, when you call
source.setUrl()
, the currently rendered tiles are not cleared. Instead, new tiles are loaded and rendered in place of existing tiles after the load.This means that
source.setUrl()
can (and should) be used for "smooth rendering" on changes (as was the original intent with #3660. In cases where people want to completely clear currently rendered tiles,source.refresh()
can be called. Alternatively,layer.setSource()
can be used to erase currently rendered tiles and render new tiles as they load.I'm still interested to see if the perceived performance of interim tile loading/rendering can be improved (see #4455). But this is a separate issue. This change only makes it so all
ol.source.Tile
can use the same mechanism.