Remove static members from Stamen
This commit is contained in:
+43
-39
@@ -5,58 +5,23 @@ import {inherits} from '../index.js';
|
|||||||
import OSM from '../source/OSM.js';
|
import OSM from '../source/OSM.js';
|
||||||
import XYZ from '../source/XYZ.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
|
* @const
|
||||||
* @type {Array.<string>}
|
* @type {Array.<string>}
|
||||||
*/
|
*/
|
||||||
Stamen.ATTRIBUTIONS = [
|
const ATTRIBUTIONS = [
|
||||||
'Map tiles by <a href="https://stamen.com/">Stamen Design</a>, ' +
|
'Map tiles by <a href="https://stamen.com/">Stamen Design</a>, ' +
|
||||||
'under <a href="https://creativecommons.org/licenses/by/3.0/">CC BY' +
|
'under <a href="https://creativecommons.org/licenses/by/3.0/">CC BY' +
|
||||||
' 3.0</a>.',
|
' 3.0</a>.',
|
||||||
OSM.ATTRIBUTION
|
OSM.ATTRIBUTION
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Object.<string, {extension: string, opaque: boolean}>}
|
* @type {Object.<string, {extension: string, opaque: boolean}>}
|
||||||
*/
|
*/
|
||||||
Stamen.LayerConfig = {
|
const LayerConfig = {
|
||||||
'terrain': {
|
'terrain': {
|
||||||
extension: 'jpg',
|
extension: 'jpg',
|
||||||
opaque: true
|
opaque: true
|
||||||
@@ -103,10 +68,11 @@ Stamen.LayerConfig = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Object.<string, {minZoom: number, maxZoom: number}>}
|
* @type {Object.<string, {minZoom: number, maxZoom: number}>}
|
||||||
*/
|
*/
|
||||||
Stamen.ProviderConfig = {
|
const ProviderConfig = {
|
||||||
'terrain': {
|
'terrain': {
|
||||||
minZoom: 4,
|
minZoom: 4,
|
||||||
maxZoom: 18
|
maxZoom: 18
|
||||||
@@ -120,4 +86,42 @@ Stamen.ProviderConfig = {
|
|||||||
maxZoom: 16
|
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;
|
export default Stamen;
|
||||||
|
|||||||
Reference in New Issue
Block a user