Merge pull request #12141 from kikitte/main

call the success callback after the features are added
This commit is contained in:
Andreas Hocevar
2021-03-25 08:19:53 +01:00
committed by GitHub
2 changed files with 19 additions and 1 deletions
+1 -1
View File
@@ -156,10 +156,10 @@ export function xhr(url, format) {
* projection. * projection.
*/ */
function (features, dataProjection) { function (features, dataProjection) {
source.addFeatures(features);
if (success !== undefined) { if (success !== undefined) {
success(features); success(features);
} }
source.addFeatures(features);
}, },
/* FIXME handle error */ failure ? failure : VOID /* FIXME handle error */ failure ? failure : VOID
); );
+18
View File
@@ -571,6 +571,24 @@ describe('ol.source.Vector', function () {
); );
}); });
it('fires the FEATURESLOADEND event after the features are added', function (done) {
const source = new VectorSource({
format: new GeoJSON(),
url: 'spec/ol/source/vectorsource/single-feature.json',
});
source.on('featuresloadend', function () {
const features = source.getFeatures();
expect(features).to.be.an('array');
expect(features.length).to.be(1);
done();
});
source.loadFeatures(
[-10000, -10000, 10000, 10000],
1,
getProjection('EPSG:3857')
);
});
it('fires the FEATURESLOADEND event if the default load function is used', function (done) { it('fires the FEATURESLOADEND event if the default load function is used', function (done) {
const source = new VectorSource({ const source = new VectorSource({
format: new GeoJSON(), format: new GeoJSON(),