Expose coveringTiles()
in transform objects
#5239
Closed
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.
Launch Checklist
CHANGELOG.md
under the## main
section.Description
Before the work on globe, the function
.coveringTiles()
used to be a method of theTransform
object, it was very convenient to access the list of tiles (with z, x and y indices) that were currently displayed. This PR aims at bringing this function back to themap.transform
object.Motivations
We (at MapTiler but we are not the only ones) are creating tiled layers to display raster data. These tiles are WebGL polygons with the same footprints as regular raster tiles, just with custom shaders. When only using Mercator it was fairly easy to figure out the math to know what tile should be displayed, but with the globe view, it is much more difficult. Since the list of tiles is computed internally in Maplibre, it would be great to expose it so that third-party plugins can use it.
Contrary to a previous PR I submitted (#5158), this one does not add any function or object to the official public API.
Usage
The
tileSize
attribute is the only one mandatory (as in the internalcoveringTiles()
function). Since it's the default size is always512
, we could make it the default value if not provided.