Merge pull request #9250 from ahocevar/clear-refresh
Clearer behaviour of clear() and refresh() on sources
This commit is contained in:
@@ -145,7 +145,7 @@ class Source extends BaseObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes the source and finally dispatches a 'change' event.
|
||||
* Refreshes the source. The source will be cleared, and data from the server will be reloaded.
|
||||
* @api
|
||||
*/
|
||||
refresh() {
|
||||
|
||||
@@ -300,12 +300,20 @@ class TileSource extends Source {
|
||||
return withinExtentAndZ(tileCoord, tileGrid) ? tileCoord : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all cached tiles from the source. The next render cycle will fetch new tiles.
|
||||
* @api
|
||||
*/
|
||||
clear() {
|
||||
this.tileCache.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
refresh() {
|
||||
this.tileCache.clear();
|
||||
this.changed();
|
||||
this.clear();
|
||||
super.refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -498,7 +498,6 @@ class VectorSource extends Source {
|
||||
if (this.featuresRtree_) {
|
||||
this.featuresRtree_.clear();
|
||||
}
|
||||
this.loadedExtentsRtree_.clear();
|
||||
this.nullGeometryFeatures_ = {};
|
||||
|
||||
const clearEvent = new VectorSourceEvent(VectorEventType.CLEAR);
|
||||
@@ -894,6 +893,15 @@ class VectorSource extends Source {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
refresh() {
|
||||
this.clear(true);
|
||||
this.loadedExtentsRtree_.clear();
|
||||
super.refresh();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove an extent from the list of loaded extents.
|
||||
@@ -977,7 +985,7 @@ class VectorSource extends Source {
|
||||
|
||||
|
||||
/**
|
||||
* Set the new loader of the source. The next loadFeatures call will use the
|
||||
* Set the new loader of the source. The next render cycle will use the
|
||||
* new loader.
|
||||
* @param {import("../featureloader.js").FeatureLoader} loader The loader to set.
|
||||
* @api
|
||||
@@ -986,6 +994,16 @@ class VectorSource extends Source {
|
||||
this.loader_ = loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Points the source to a new url. The next render cycle will use the new url.
|
||||
* @param {string|import("../featureloader.js").FeatureUrlFunction} url Url.
|
||||
* @api
|
||||
*/
|
||||
setUrl(url) {
|
||||
assert(this.format_, 7); // `format` must be set when `url` is set
|
||||
this.setLoader(xhr(url, this.format_));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user