Allow tileUrlFunction to be called on small resolution changes (even when gridZoom {z} remains constant)
See original GitHub issueI’m trying to load tiles from different subdomains of a custom XYZ source depending on the current resolution (viewZoom). Different resolutions of the view might be associated with different subdomains but with identical gridZoom. In this case, the tileUrlFunction
cannot be called.
viewZoom zoom subdomain
0 1.0 subdomain1
1 1.2 subdomain1
2 1.4 subdomain2
3 1.6 subdomain3
gridZoom = Math.round(zoom);
Several approaches exist to enable loading from different sources (see here for a more detailed description) but they seem to be lacking some of the advantages of the tileUrlFunction
(before zoom: preload adjacent zoom levels; on zoom: resize old tiles, then load new tiles, then remove old tiles).
Use case: Semantic zooming, map with several levels of detail which might be shown at intermediate zoom steps without changing the scale enough to alter gridZoom (e. g. administrative borders at a continental, national and regional scale; my use case is a biological map where I try to show different steps of a taxonomic hierarchy).
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Tiles from services such such as OSM and MapTiler sometimes fail to update if the server is busy (and browser caching means the problem can recur even after closing and reopening the map). When zoom levels have similar styles you might not notice, but with different styles it will be more noticeable - you could try setting
useInterimTilesOnError: false
as a layer option to prevent display of the old tiles.With a vector layer you can change styles (or set empty style to hide features) using the style function’s resolution parameter, but if you need to clear and reload the data you would need to listen for
change:resolution
events on the view or use multiple layers (possibly withminResolution
andmaxResolution
options).It could be done using a custom tile grid which specifies the resolutions and tile sizes you would like and whatever is served fits into those https://codesandbox.io/s/simple-bg7d4