Add 'rendercomplete' event

This commit is contained in:
ahocevar
2018-08-21 17:29:10 +02:00
parent 3f98094d9d
commit 1baa8be269
11 changed files with 128 additions and 60 deletions

View File

@@ -201,16 +201,19 @@ class ImageSource extends Source {
const image = /** @type {module:ol/Image} */ (event.target);
switch (image.getState()) {
case ImageState.LOADING:
this.loading = true;
this.dispatchEvent(
new ImageSourceEvent(ImageSourceEventType.IMAGELOADSTART,
image));
break;
case ImageState.LOADED:
this.loading = false;
this.dispatchEvent(
new ImageSourceEvent(ImageSourceEventType.IMAGELOADEND,
image));
break;
case ImageState.ERROR:
this.loading = false;
this.dispatchEvent(
new ImageSourceEvent(ImageSourceEventType.IMAGELOADERROR,
image));

View File

@@ -66,6 +66,13 @@ class Source extends BaseObject {
*/
this.attributions_ = this.adaptAttributions_(options.attributions);
/**
* This source is currently loading data. Sources that defer loading to the
* map's tile queue never set this to `true`.
* @type {boolean}
*/
this.loading = false;
/**
* @private
* @type {module:ol/source/State}

View File

@@ -871,6 +871,7 @@ class VectorSource extends Source {
loadFeatures(extent, resolution, projection) {
const loadedExtentsRtree = this.loadedExtentsRtree_;
const extentsToLoad = this.strategy_(extent, resolution);
this.loading = false;
for (let i = 0, ii = extentsToLoad.length; i < ii; ++i) {
const extentToLoad = extentsToLoad[i];
const alreadyLoaded = loadedExtentsRtree.forEachInExtent(extentToLoad,
@@ -884,6 +885,7 @@ class VectorSource extends Source {
if (!alreadyLoaded) {
this.loader_.call(this, extentToLoad, resolution, projection);
loadedExtentsRtree.insert(extentToLoad, {extent: extentToLoad.slice()});
this.loading = true;
}
}
}