question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow tileUrlFunction to be called on small resolution changes (even when gridZoom {z} remains constant)

See original GitHub issue

I’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:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mike-000commented, Dec 22, 2019

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 with minResolution and maxResolution options).

1reaction
mike-000commented, Dec 20, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

OpenLayers: Smoothly change tile source on zoom
For simplicity, I'm giving the actual zoom values for each viewZoom step instead of the resolutions. Therefore, gridZoom = Math.round(zoom) .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found