ol-mapbox-style icon indicating copy to clipboard operation
ol-mapbox-style copied to clipboard

VectorTile layers with source `minZoom` 0 not visible when view is zoomed out

Open mike-000 opened this issue 1 year ago • 1 comments

Open https://openlayers.org/en/v6.14.1/examples/vector-tiles-4326.html in a window with width 1024px or less, the layer is visible.

Repeat with https://openlayers.org/en/latest/examples/vector-tiles-4326.html the layer is not visible until the view is zoomed in to just beyond level 2.

The same problem can be seen in https://openlayers.org/en/latest/examples/mapbox-vector-layer.html if zooming out to level 1 or less in a smaller (512px or less) window.

This was introduced by #520 (and later moved to apply.js), however there was already code which takes care not to set a maxResolution on layers if the source minZoom is 0 https://github.com/openlayers/ol-mapbox-style/blob/main/src/apply.js#L1206 while the new code simply sets maxResolution regardless https://github.com/openlayers/ol-mapbox-style/blob/main/src/apply.js#L315

For comparison MapLibre has no problem displaying layers at resolutions beyond that of OpenLayers view zoom 0 image (which instead of a multiWorld constraint uses the equivalent of an OpenLayers [-Infinity, minY, +Infinity, maxY] extent constraint).

mike-000 avatar Oct 01 '23 14:10 mike-000

In both the examples adding minZoom: 0 to the layer options prevents the maxResolution being set inappropriately, but it would be better to fix this at the cause.

While this issue is specific to applyStyle and MapboxVectorLayer the code in finalizeLayer from which any fix would be based looks out of date as it should now be able to handle non-standard projections but always uses defaultResolutions. Should that now be options.resolutions || defaultResolutions (with the hardcoded 24 changed to match that length)? And when units are degrees simply adding 1e-9 to a resolution might not give a good result, multiplying by (1 + 1e-9) might be more appropriate.

mike-000 avatar Oct 02 '23 15:10 mike-000