Leaflet / Leaflet.VectorGrid

Display gridded vector data (sliced GeoJSON or protobuf vector tiles) in Leaflet 1.0.0
598 stars 194 forks source link

Vector Tiles don't scale up smoothly with Canvas renderer #164

Open Excape opened 6 years ago

Excape commented 6 years ago

I'm using vector tiles that go up to zoom level 13, so i set the maxNativeZoom to 13. When i allow a maxZoom higher than that, e.g. 17, the layer should scale up.

With rendererFactory: L.svg.tile, this works fine: image

This slower in performance than L.canvas.tile however. With that however, the scaled-up version looks blurry: image

BTW, I'm using the [ react-leaflet ](https://github.com/PaulLeCam/react-leaflet plugin) plugin with a custom component where i call leaflet directly, like in this issue

Is there some inherent reason how canvas gets rendered, or is that an issue with the canvas renderer?

IvanSanchez commented 6 years ago

I think this is behaviour as expected. If you use a maxZoom higher than maxNativeZoom on any L.TileLayer, the image will appear pixellated in the same fashion.

Is there some inherent reason how canvas gets rendered, or ...?

This is how <canvas>es work. Leaflet's L.Canvas renderer rasterizes the vector data into pixels.

You could argue "but it might be better to re-rasterize the <canvas> tiles on zoom change, doubling up their (width and height) size at each zoom threshold", to which I would reply "yeah, but that's extra work, and doubling up the size of canvases might create canvases larger than the screen and too large for the GPU, so if you want to re-rasterize stuff at zoom thresholds you will be better setting up a higher maxNativeZoom value anyway".

I'm partial to closing this as "it's a feature, not a bug". I don't think there's anything valuable to be done about this.