Data sources can define specific zoom levels at which tiles are loaded #702
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, tiled data sources request data at every map zoom level. There are some parameters that affect the mapping between the "view" zoom and the "tile" zoom (
tile_size
,zoom_offset
), but these still trigger a new load at each zoom level.There are some cases where it may be unnecessary or undesirable to load new tile data this frequently. This PR extends the syntax for data sources, with a new
zooms
parameter that can specify a list of zoom levels at which new data should be loaded.For example, to only load new tile data at every other zoom level:
Or, an application with two logical levels -- such as a zoomed out and zoomed in view -- could define these explicitly, for example:
zooms: [4, 12]
.For view zooms in between these defined tile zooms, the tile for the next lowest available zoom will be overzoomed; in this sense, this feature extends and allows for more control of our existing overzooming behavior. For example, if
zooms: [4, 8, 12, 16]
, when viewing the map at zoom 14, the zoom 12 tile will be overzoomed (note, this assumes 256px tiles).Default / Max / Min Zooms
When
zooms
is undefined, the current behavior is used (tiles load at all zooms). If bothzooms
andmax_zoom
is present, the last zoom listed inzooms
takes precedence, and overrides themax_zoom
parameter. Themin_display_zoom
also automatically defaults to the first entry in thezooms
list (e.g. ifzooms: [4, 8, 12, 16]
, thenmin_display_zoom
defaults to 4).Other Zoom Adjustment Parameters
The
tile_size
andzoom_offset
parameters can be mixed withzooms
, and continue to behave as they do currently, by lowering the potential tile zoom requested for a given view zoom. For example, with this combination:A given view zoom will look for a tile zoom that is 3 levels lower (1 level for 512px tiles, plus 2 more for the
zoom_offset
). Thus at a view zoom of 12, the data source will look for the z9 tile, and then request/overzoom the z8 tile instead (the next available level defined inzooms
). But at zoom 14, the data source will look for a z11 tile -- and will also use the z8 tile, since the requested level falls below the z12 thresholds in zooms, even though the map view zoom is above it; in this example, the z12 tile will not be requested until the view zoom is z15 (note, this is a somewhat extreme/contrived example for illustration).