The OpenLayers folks gave us a good starting off point with https://openlayers.org/en/latest/examples/vector-esri.html but it is lacking in at least one way. If you modify that example by setting the initial zoom level to 0 the request for features will fail to return all of them. Only one query will return results:
This URL will return 1000 features and the tileStrategy (or maybe VectorSource) has no idea that this is an indication of a partial result and happily marks that tile as fully loaded.
So my question is directed to anyone that as either solved or is aware of an existing solution to effectively render ArcGIS FeatureServer data on an OpenLayers map.
I have found one very bad solution:
map.on('moveend', () => {
vectorSource.refresh();
});
It will clear the entire tile cache and re-query for all features. I would like to limit the "refresh" to just those tile that represent 1000 features (or whatever represents the max feature count).
The beginnings of a solution may be to record all extents that return 1000 features and not even render them:
if (1000 === features.length) {
extentsToClear.push(extent);
} else {
vectorSource.addFeatures(features);
}
When the map extent changes, clear these extents:
map.on("moveend", () => {
while (extentsToClear.length) {
vectorSource.removeLoadedExtent(extentsToClear.pop());
}
});