openlayers / openlayers

OpenLayers
https://openlayers.org
BSD 2-Clause "Simplified" License
11.17k stars 3.01k forks source link

Handle arcgis vector-tile services tilemap #15335

Open JohnAtle opened 8 months ago

JohnAtle commented 8 months ago

Some arcgis vector-tile services uses a "vector tilemap" to define what tiles exist in the tilgrid. See https://developers.arcgis.com/rest/services-reference/enterprise/vector-tilemap.htm and https://developers.arcgis.com/rest/services-reference/enterprise/tile-map.htm

When requesting tiles not defined in the tilemap, we get a "204 - No content" in response, and a blank tile is shown in the map.

A workaround is to define a setTileLoadFunction that when getting a 204 response, will do a request on the above zoom-levels until a tile is found and use this. See https://codesandbox.io/s/blank-arcgis-vector-tiles-workaround-3v5xnz

I would request either (in prioritized order):

ottarv commented 8 months ago

Excellent suggestion and nice workaround. Note that 404 - Not found should be treated the same as 204 - No content when requesting vector tiles from arcgis.

rdewit commented 8 months ago

FWIW, if you have control over the generation of the vector tile package, setting the 'Tiling Format' to 'Flat' (as opposed to 'Indexed', which is the default), the availability of the tiles will be predictable, i.e. there should not be any gaps in the tile availability. And the 'Index Polygons' setting may need to be blank (not sure about that).

@JohnAtle , I noticed that the layer you point to in your workaround has absolute paths to the sprites, glyphs and tiles. Most other ArcGIS tile services use relative paths, which are not supported directly by openlayers or maplibre-gl. Do you know how to configure these services to use absolute paths?

JohnAtle commented 8 months ago

@rdewit Thanks for the information about the 'Tiling Format', that is very interesting. Unfortunately I do not have any control over the ArcGIS services so I can not change this. (I have never set up an ArcGIS service, so I am sorry I can not help with the use of absolute path.)