Leaflet / Leaflet/Leaflet.VectorGrid
Rework maxNativeZoom
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 676
- Forks
- 202
- PR merge metrics
- No merged PRs in 30d
Description
As @jkuebart pointed out:
It's interesting to note that by using
maxNativeZoomas implemented byGridLayer, vector tiles will not be re-rendered at higher zoom levels. Consequently, the stroke width is scaled up along with the tile, while with the previous solution given above the stroke width remained constant.
If
maxNativeZoomis only used because there is sufficient detail at a particular zoom level, this might not be the intended effect. If the stroke width should remain visually constant across all zoom levels, a vector tile layer might still need to reimplementgetTileSize()andcreateTile()accordingly.
I think this is a valid concern, and deserves its own issue.
A tentative approach would be to:
- Override
L.GridLayer._clampZoomand replace it with an identity function - Calculate the "data tile" to be fetched for a given "display tile"
- Multiply
pxPerExtentby (2 to the power of the zoom delta) - Calculate some
pxOffsetfor when the "data tile" and "display tile" are not aligned at their top left corners - Use that
pxOffsetin all coordinate calculations inPointLayer,PolylineLayerandPolygonLayer
Another approach would be:
- Keep the current
_clampZoomlogic - On a
zoomendevent, iterate through all the tiled renderers (there's a reference inthis._vectorTiles) and- Reset the size of the containers of the tiled renderers by a factor of (2 to the power of zoom delta)
- Trigger an update of the tiled renderers
First approach doesn't sound too easy, and might need re-requesting tiles. Second approach sounds simpler, almost too simple.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the current GridLayer._clampZoom behavior and the PointLayer, PolylineLayer, and PolygonLayer coordinate calculations. Compare the two proposed approaches around zoomend, this._vectorTiles, data tiles, and display tiles. Done means maxNativeZoom supports higher display zooms while preserving visually constant stroke widths and correct tile alignment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100