call the success callback after the features are added

This commit is contained in:
kikitte.lee
2021-03-25 13:16:35 +08:00
parent 22ff477ee6
commit 635191f31d
2 changed files with 19 additions and 1 deletions

View File

@@ -156,10 +156,10 @@ export function xhr(url, format) {
* projection.
*/
function (features, dataProjection) {
source.addFeatures(features);
if (success !== undefined) {
success(features);
}
source.addFeatures(features);
},
/* FIXME handle error */ failure ? failure : VOID
);

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) {
const source = new VectorSource({
format: new GeoJSON(),