Add a getUrls Method to ol.source.XYZ

Added the getUrls method to get access to the url / urls property.
When using a tileUrlFunction, getUrls should return null.
This should fix issue #3886
This commit is contained in:
Johannes Weskamm
2015-08-19 09:58:06 +02:00
parent 33da0e7b66
commit a6c49dabcf
2 changed files with 75 additions and 0 deletions

View File

@@ -115,6 +115,61 @@ describe('ol.source.XYZ', function() {
});
describe('#getUrls', function() {
var sourceOptions;
var source;
var url = 'http://geo.nls.uk/maps/towns/glasgow1857/{z}/{x}/{-y}.png';
beforeEach(function() {
sourceOptions = {
projection: 'EPSG:4326'
};
});
describe('using a "url" option', function() {
beforeEach(function() {
sourceOptions.url = url;
source = new ol.source.XYZ(sourceOptions);
});
it('returns the XYZ URL', function() {
var urls = source.getUrls();
expect(urls).to.be.eql([url]);
});
});
describe('using a "urls" option', function() {
beforeEach(function() {
sourceOptions.urls = ['some_xyz_url1', 'some_xyz_url2'];
source = new ol.source.XYZ(sourceOptions);
});
it('returns the XYZ URLs', function() {
var urls = source.getUrls();
expect(urls).to.be.eql(['some_xyz_url1', 'some_xyz_url2']);
});
});
describe('using a "tileUrlFunction"', function() {
beforeEach(function() {
sourceOptions.tileUrlFunction = function() {
return 'some_xyz_url';
};
source = new ol.source.XYZ(sourceOptions);
});
it('returns null', function() {
var urls = source.getUrls();
expect(urls).to.be(null);
});
});
});
});
goog.require('ol.TileCoord');