We have a custom loader for our vector source which sets the current resolution on the source and clears the source before loading the data via xhr from our spatial data API.
The custom strategy checks whether the resolution argument is different to the current resolution. The loadedExtentsRtree_ of the source will be cleared if the resolution is different. Clearing the extents tree ensures that the loader will be called with the transformed extent as argument.
Unfortunately we have no longer access to the loadedExtentsRtree_ object of the vector source in Openlayers 6.6.
Is there a way to clear the extents tree directly with OL 6.6?
new ol.source.Vector({
loader: function (extent, resolution, projection) {
this.resolution = resolution
this.clear(true)
xhr && xhr.abort()
//create a new xhr request to load data
},
strategy: function(extent, resolution) {
this.resolution != resolution && this.loadedExtentsRtree_.clear()
return [ol.proj.transformExtent(extent, map_projection, data_projection)]
}
.removeLoadedExtentmethod? – TomazicM Jul 22 '21 at 13:56source,clear()in the strategy function but make sure the extent has changed to avoid getting into a loop (clearing the source in the loader can also cause loops). See https://gis.stackexchange.com/questions/322681/openlayers-refresh-vector-source-with-bbox-strategy-after-map-moved – Mike Jul 22 '21 at 14:25