mapbox-gl-js icon indicating copy to clipboard operation
mapbox-gl-js copied to clipboard

Ability to cancel request in `requestTransform` for overzooming purposes

Open dee-cf opened this issue 1 year ago • 0 comments

Motivation

I am trying to implement overzooming so that I don't need to load vector tile source for each zoom level but just for some. It would be great to be able to parse zoom levels for which I need to get data from server and for which I can cancel a request.

For example, lets say my tiles extent is such that I can overzoom 3 levels. that means, if I want some data from the source to show on zoom levels 15-21, I could:

15 > load 16, 17 > cancel 18 > load 19,21 > cancel

this way I could save 4 requests per source.

Design Alternatives

The way we can do it now is to have separate layer per zoom level range each with its corresponding source: 15-17 > layer15-17 > source15 18-21 > layer18-21 > source18

alternative approach might be to be able to define an array of zoom levels (within minZoom-maxZoom range) for which source should be loaded. This would be an optional parameter on the source.

Design

The advantage of being able to cancel/skip the request based on zoom level is simplification on layers side (single layer instead of many): we keep single layer with single source and introduce stepped requests based on overzooming strategy.

dee-cf avatar Aug 19 '24 13:08 dee-cf