protomaps-leaflet icon indicating copy to clipboard operation
protomaps-leaflet copied to clipboard

High resolution tiles?

Open chriscdn opened this issue 1 year ago • 8 comments

Is there a setting or option for increasing the map resolution (e.g., retina tiles)?

I know tileSize can be used to increase the map resolution with Leaflet, but I don't see this as an option to protomapsL.leafletLayer. Is there a way to do this?

chriscdn avatar May 15 '24 19:05 chriscdn

The tile resolution should match your devicePixelRatio and be the ideal resolution automatically, so there isn't a way to set it:

https://github.com/protomaps/protomaps-leaflet/blob/main/src/frontends/leaflet.ts#L107

bdon avatar May 16 '24 03:05 bdon

Thanks, I see that now. I was using it in a headless environment, and was able to apply it by setting the deviceScaleFactor.

It would be great if this could be made into an optional parameter (defaulting to devicePixelRatio) for such cases. I'd be happy to submit a pull request.

chriscdn avatar May 16 '24 06:05 chriscdn

In the case you described shouldn't setting deviceScaleFactor in Puppeteer be sufficient for control over this?

bdon avatar May 16 '24 08:05 bdon

I suppose my concern is introducing side effects in my application by changing deviceScaleFactor. However, it does seem to work. I just prefer more explicit parameters to clearly define behaviour, rather than depending on a global that's set in a completely different area of my application. A parameter would make it clear.

chriscdn avatar May 16 '24 20:05 chriscdn

I agree, do you want to try a PR where devicePixelRatio is an option to leafletLayer?

bdon avatar May 20 '24 07:05 bdon

Sure, I'd be happy to. However, I see window.devicePixelRatio is also used in a few other locations. I could extend these interfaces in a similar way.

Should the parameter be named scale or something, which defaults to window.devicePixelRatio? Naming the parameter devicePixelRatio might be confusing since you're not actually changing the device pixel ratio. :)

chriscdn avatar May 25 '24 09:05 chriscdn

scale can mean something different and I think devicePixelRatio used like

this.devicePixelRatio || window.devicePixelRatio

is the most straightforward...

since you're not actually changing the device pixel ratio

It seems fine to me if the main use case is for headless "devices", right?

bdon avatar May 28 '24 08:05 bdon