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

setLayerZoomRange causing rasters to be re-requested #7865

Closed
nreese opened this issue Feb 1, 2019 · 3 comments · Fixed by #8854
Closed

setLayerZoomRange causing rasters to be re-requested #7865

nreese opened this issue Feb 1, 2019 · 3 comments · Fixed by #8854
Assignees
Labels

Comments

@nreese
Copy link

nreese commented Feb 1, 2019

Whenever setLayerZoomRange is called with new min/max values on a layer containing raster tiles, all tiles are requested. Is this expected behavior? I am using mapbox-gl version 0.45.0 in Chrome 71.0.3578.98.

Below is the code used to create the layer.

    mbMap.addSource(sourceId, {
      type: 'raster',
      tiles: [url],
      tileSize: 256,
      scheme: 'xyz',
    });

    mbMap.addLayer({
      id: mbLayerId,
      type: 'raster',
      source: sourceId,
      minzoom: 0,
      maxzoom: 22,
    });

Then if mbMap.setLayerZoomRange(mbLayerId, 0, 15); is called, all tiles are re-fetched. Why are the tiles re-fetched? The map is at zoom level 3 so the change should have no effect on the current tiles.

@mourner
Copy link
Member

mourner commented Feb 1, 2019

@nreese

  • Did you make sure the behavior is the same on the latest version, v0.52.0 or v0.53.0-beta.1?
  • Can you set up a minimal reproducible test case to demonstrate this (e.g. with JSFiddle)?

@nreese
Copy link
Author

nreese commented Feb 1, 2019

@mourner The problem exists in v0.52.0. Here is a js-fiddle that demonstrates the problem https://jsfiddle.net/reesenathan/pwb6nz74/. Adjust the slider in the top left corner and notice that when you release the slider and setLayerZoomRange is triggered, the tiles flicker because they are getting re-fetched.

@peterqliu
Copy link
Contributor

peterqliu commented Feb 5, 2019

Looks like killing this line removes the flicker, while preserving the method functionality both when inside the new zoom range or not:

this._updateLayer(layer);

any downsides to not reloading the layer source after calling setLayerZoomRange, and not pausing the SourceCache, that I'm not seeing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants