Leaflet / Leaflet/Leaflet.VectorGrid

Rework maxNativeZoom

Open
#74 11 comments 0 reactions 0 assignees View on GitHub

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 maxNativeZoom as implemented by GridLayer, 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 maxNativeZoom is 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 reimplement getTileSize() and createTile() accordingly.

I think this is a valid concern, and deserves its own issue.

A tentative approach would be to:

  • Override L.GridLayer._clampZoom and replace it with an identity function
  • Calculate the "data tile" to be fetched for a given "display tile"
  • Multiply pxPerExtent by (2 to the power of the zoom delta)
  • Calculate some pxOffset for when the "data tile" and "display tile" are not aligned at their top left corners
  • Use that pxOffset in all coordinate calculations in PointLayer, PolylineLayer and PolygonLayer

Another approach would be:

  • Keep the current _clampZoom logic
  • On a zoomend event, iterate through all the tiled renderers (there's a reference in this._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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.