protomaps / protomaps-leaflet

Lightweight vector map rendering + labeling and symbology for Leaflet
https://protomaps.com/docs/frontends/leaflet
BSD 3-Clause "New" or "Revised" License
767 stars 43 forks source link

Fractional display zoom support in Static frontend #171

Closed saranrapjs closed 2 months ago

saranrapjs commented 2 months ago

I've been using the Static frontend for protomaps as a way to render a not-really-interactive map without incurring a lot of extra page weight. It's great! I accidentally discovered recently that it's possible to pass in fractional display zoom levels to map instance methods like drawContext or drawCanvas — e.g. await map.drawCanvas(canvas, { x, y }, 15.5) and the canvas rendering basically just works. This can be handy when working with small canvas dimensions, where the whole number zoom levels can force you into too-big or too-small rendering.

The one caveat with fractional display zooms is that the project method returned from these calls doesn't work — something about the coordinate math doesn't appear to sit well with fractional zooms, and the canvas coordinates returned by project are much larger and rendered off screen.

I'm wondering: should fractional zooms theoretically be supported here? I'd be happy to help with a patch if they should work (but don't); but if it's non-standard or not part of the API design to support fractional zooms, I'd be equally happy to close this issue!

bdon commented 2 months ago

4.0.1 published, thanks! https://www.npmjs.com/package/protomaps-leaflet