Search code examples
openlayersvector-tiles

VectorTile Layer not updating


I am having a strange issue when using ol.layer.VectorTile layer using openlayers 4.2.0.

For the ol.source.VectorTile I am using a tileLoadFunction to make network requests for the tiles in my tileGrid. I have about 100 points on my map in the layer. There are certain options a user can choose, which will go to a function where the VectorTile layer and VectorTile source are redefined, and the layer is removed and read, so that new points are drawn on the map.

Things seem to be fine after switching the layer a few times, but eventually, the tileLoadFunction stops getting called. Sometimes it will get called like 3 times or something but then stops getting called, even though there are many more tiles in the tileGrid. I am not sure what is happening, like it is reaching some kind of limit or something that is preventing it from calling the tileLoadFunction? I have tried to use the .refresh() on the source in case this is the problem, but that did nothing to help.


Solution

  • I had a check for whether there were any features in the data for a given tile, and if not I skipped the tile.setFeatures() function for that tile. This messed something up in the scheme of things.

    The solution was to not check for data, and just setFeatures with an empty featureCollection if the data did not have any features for a particular tile.