Add layerName and layers options to ol.source.TopoJSON

This commit is contained in:
Andreas Hocevar
2017-05-16 16:19:33 +02:00
parent 342c49f0bb
commit 7ecb2c0185
6 changed files with 154 additions and 80 deletions

View File

@@ -176,6 +176,29 @@ describe('ol.format.TopoJSON', function() {
});
});
it('sets the topology\'s child names as feature property', function(done) {
afterLoadText('spec/ol/format/topojson/world-110m.json', function(text) {
var format = new ol.format.TopoJSON({
layerName: 'layer'
});
var features = format.readFeatures(text);
expect(features[0].get('layer')).to.be('land');
expect(features[177].get('layer')).to.be('countries');
done();
});
});
it('only parses features from specified topology\'s children', function(done) {
afterLoadText('spec/ol/format/topojson/world-110m.json', function(text) {
var format = new ol.format.TopoJSON({
layers: ['land']
});
var features = format.readFeatures(text);
expect(features.length).to.be(1);
done();
});
});
});
});