diff --git a/src/ol/source/vectorsource.js b/src/ol/source/vectorsource.js index d01ff50ddb..4d306c1065 100644 --- a/src/ol/source/vectorsource.js +++ b/src/ol/source/vectorsource.js @@ -166,6 +166,14 @@ ol.source.Vector.prototype.handleFeatureChange_ = function(event) { }; +/** + * @return {boolean} Is empty. + */ +ol.source.Vector.prototype.isEmpty = function() { + return this.rBush_.isEmpty(); +}; + + /** * @param {ol.Feature} feature Feature. */ diff --git a/test/spec/ol/source/vectorsource.test.js b/test/spec/ol/source/vectorsource.test.js index 17af7df1ab..ba7268a1ec 100644 --- a/test/spec/ol/source/vectorsource.test.js +++ b/test/spec/ol/source/vectorsource.test.js @@ -37,6 +37,14 @@ describe('ol.source.Vector', function() { }); + describe('#isEmpty', function() { + + it('returns true', function() { + expect(vectorSource.isEmpty()).to.be(true); + }); + + }); + describe('#addFeature', function() { it('can add a single point feature', function() { @@ -103,6 +111,14 @@ describe('ol.source.Vector', function() { }); + describe('#isEmpty', function() { + + it('returns false', function() { + expect(vectorSource.isEmpty()).to.be(false); + }); + + }); + describe.skip('#removeFeature', function() { it('works as expected', function() {