Incorrect Tiles being requested for projections other than Web Mercator (EPSG:3857)
MattMauser opened this issue · 2 comments
I have vector tiles that are in Canada Atlas Lambert (EPSG:3978). When I pull them into OL, I've found that data seems to disappear between breakpoints. I thought this might be an issue with the zoom levels themselves not being integer numbers, so I edited the source map to snap to the proper scales / zoom levels, but the issue persisted. Shortly after, I had also produced a Web Mercator Map version that was almost identical, so I tried pulling it into OL as well and the map showed properly with no disappearing data.
Upon closer inspection of the network traffic, I found that for the 3978 projection, it was pulling tiles from the wrong zoom level. For vector tiles, when the map is at a zoom level of 8, then it should be pulling tiles from 7, however; in my case it was pulling from 8. I'm assuming this is what was causing the data to disappear at break points because it was trying to style data that didn't appear in those tiles and didn't have the issue at other zoom levels because, even though it was pulling incorrect tiles, it still had the data present to symbolize. I think this is causing some of my labels to disappear as well at other zoom levels, but the most noticeable was the geometries. Looking at my 3857 map, it seemed to pull from the correct tiles at all times.
I'm assuming this is something that needs to be fixed in OpenLayers, but maybe there's something that I can change on my end?
3978 Map
Breakpoints at 8 and 10, data disappears between 8-9 and 10-11.
3857 Map
Breakpoints at 9 and 11, data looks fine between 9-10 and 11-12.
Since your view projection does not have a validity extent
defined, it cannot calculate suitable resolutions, and you need to pass the correct resolutions to the applyStyle()
function:
applyStyle(vectorTileLayer, styleUrl, {
resolutions: vectorTileLayer.getSource().getTileGrid().getResolutions(),
});
The above assumes that the style for that map uses the same resolutions as the tile grid.
Perfect! Thanks for the speedy response. That seems to have fixed the problem.