Remove static members from Stamen
This commit is contained in:
@@ -5,58 +5,23 @@ import {inherits} from '../index.js';
|
||||
import OSM from '../source/OSM.js';
|
||||
import XYZ from '../source/XYZ.js';
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Layer source for the Stamen tile server.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.source.XYZ}
|
||||
* @param {olx.source.StamenOptions} options Stamen options.
|
||||
* @api
|
||||
*/
|
||||
const Stamen = function(options) {
|
||||
const i = options.layer.indexOf('-');
|
||||
const provider = i == -1 ? options.layer : options.layer.slice(0, i);
|
||||
const providerConfig = Stamen.ProviderConfig[provider];
|
||||
|
||||
const layerConfig = Stamen.LayerConfig[options.layer];
|
||||
|
||||
const url = options.url !== undefined ? options.url :
|
||||
'https://stamen-tiles-{a-d}.a.ssl.fastly.net/' + options.layer +
|
||||
'/{z}/{x}/{y}.' + layerConfig.extension;
|
||||
|
||||
XYZ.call(this, {
|
||||
attributions: Stamen.ATTRIBUTIONS,
|
||||
cacheSize: options.cacheSize,
|
||||
crossOrigin: 'anonymous',
|
||||
maxZoom: options.maxZoom != undefined ? options.maxZoom : providerConfig.maxZoom,
|
||||
minZoom: options.minZoom != undefined ? options.minZoom : providerConfig.minZoom,
|
||||
opaque: layerConfig.opaque,
|
||||
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
||||
tileLoadFunction: options.tileLoadFunction,
|
||||
url: url,
|
||||
wrapX: options.wrapX
|
||||
});
|
||||
};
|
||||
|
||||
inherits(Stamen, XYZ);
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<string>}
|
||||
*/
|
||||
Stamen.ATTRIBUTIONS = [
|
||||
const ATTRIBUTIONS = [
|
||||
'Map tiles by <a href="https://stamen.com/">Stamen Design</a>, ' +
|
||||
'under <a href="https://creativecommons.org/licenses/by/3.0/">CC BY' +
|
||||
' 3.0</a>.',
|
||||
OSM.ATTRIBUTION
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @type {Object.<string, {extension: string, opaque: boolean}>}
|
||||
*/
|
||||
Stamen.LayerConfig = {
|
||||
const LayerConfig = {
|
||||
'terrain': {
|
||||
extension: 'jpg',
|
||||
opaque: true
|
||||
@@ -103,10 +68,11 @@ Stamen.LayerConfig = {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @type {Object.<string, {minZoom: number, maxZoom: number}>}
|
||||
*/
|
||||
Stamen.ProviderConfig = {
|
||||
const ProviderConfig = {
|
||||
'terrain': {
|
||||
minZoom: 4,
|
||||
maxZoom: 18
|
||||
@@ -120,4 +86,42 @@ Stamen.ProviderConfig = {
|
||||
maxZoom: 16
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Layer source for the Stamen tile server.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.source.XYZ}
|
||||
* @param {olx.source.StamenOptions} options Stamen options.
|
||||
* @api
|
||||
*/
|
||||
const Stamen = function(options) {
|
||||
const i = options.layer.indexOf('-');
|
||||
const provider = i == -1 ? options.layer : options.layer.slice(0, i);
|
||||
const providerConfig = ProviderConfig[provider];
|
||||
|
||||
const layerConfig = LayerConfig[options.layer];
|
||||
|
||||
const url = options.url !== undefined ? options.url :
|
||||
'https://stamen-tiles-{a-d}.a.ssl.fastly.net/' + options.layer +
|
||||
'/{z}/{x}/{y}.' + layerConfig.extension;
|
||||
|
||||
XYZ.call(this, {
|
||||
attributions: ATTRIBUTIONS,
|
||||
cacheSize: options.cacheSize,
|
||||
crossOrigin: 'anonymous',
|
||||
maxZoom: options.maxZoom != undefined ? options.maxZoom : providerConfig.maxZoom,
|
||||
minZoom: options.minZoom != undefined ? options.minZoom : providerConfig.minZoom,
|
||||
opaque: layerConfig.opaque,
|
||||
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
||||
tileLoadFunction: options.tileLoadFunction,
|
||||
url: url,
|
||||
wrapX: options.wrapX
|
||||
});
|
||||
};
|
||||
|
||||
inherits(Stamen, XYZ);
|
||||
|
||||
export default Stamen;
|
||||
|
||||
Reference in New Issue
Block a user