Open chriszrc opened 6 years ago
No, there is no support for this right now. This makes for a great feature request, though.
I think that the easiest way to try and implement this would be to hack the tile size initialization at https://github.com/Leaflet/Leaflet.VectorGrid/blob/13315057d285bfa5d5cb74d2abb442e925825b55/src/Leaflet.VectorGrid.js#L61
With a bit of luck, just multiplying that value by window.devicePixelRatio
might just work.
Hmm,
Just making tilesize = {x:512,y:512} has the same effect as my earlier experiment, it shrinks the tiles (and they do look crisp shrunken), but they're in the wrong places. My rough understanding of canvas is that in order to get this to work, the context of the canvas needs to get scaled:
https://www.html5rocks.com/en/tutorials/canvas/hidpi/
But I don't see where to get the canvas context-
@chriszrc Hello, this is my approach.
No matter how many times the canvas is scaled, the css size of the canvas is finally set to tilesize.
@gee1k nice, thanks for sharing, I'll give it a try-
When I use the svg renderer, all the geometries look crisp on my retina display. But if I switch to canvas, the points and lines all look a little blurry. Is there any established method for handling this? This is at normal zoom levels, not overzooming.
My understanding is that the pixel resolution of the canvas has to be doubled for retina. Taking a very uneducated look at the code, I could see this:
And if I change the width/height attribute for the container to :
Everything looks very crisp indeed! But also now the coordinates are off. Does anyone know the full list (or right way) to make this modification? Increase the tile size of the protobuf tiles? Then change the tilesize of the gridlayer? So far anything I've tried hasn't worked.