Correct Stamen source
This commit is contained in:
@@ -114,8 +114,11 @@
|
||||
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.version string|undefined
|
||||
|
||||
@exportObjectLiteral ol.source.StamenOptions
|
||||
@exportObjectLiteralProperty ol.source.StamenOptions.flavor string|undefined
|
||||
@exportObjectLiteralProperty ol.source.StamenOptions.provider string
|
||||
@exportObjectLiteralProperty ol.source.StamenOptions.layer string
|
||||
@exportObjectLiteralProperty ol.source.StamenOptions.minZoom number|undefined
|
||||
@exportObjectLiteralProperty ol.source.StamenOptions.maxZoom number|undefined
|
||||
@exportObjectLiteralProperty ol.source.StamenOptions.opaque boolean|undefined
|
||||
@exportObjectLiteralProperty ol.source.StamenOptions.url string|undefined
|
||||
|
||||
@exportObjectLiteral ol.source.StaticImageOptions
|
||||
@exportObjectLiteralProperty ol.source.StaticImageOptions.attributions Array.<ol.Attribution>|undefined
|
||||
|
||||
@@ -1,21 +1 @@
|
||||
@exportSymbol ol.source.Stamen
|
||||
|
||||
@exportSymbol ol.source.StamenFlavor
|
||||
@exportProperty ol.source.StamenFlavor.TERRAIN_BACKGROUND
|
||||
@exportProperty ol.source.StamenFlavor.TERRAIN_LABELS
|
||||
@exportProperty ol.source.StamenFlavor.TERRAIN_LINES
|
||||
@exportProperty ol.source.StamenFlavor.TONER_2010
|
||||
@exportProperty ol.source.StamenFlavor.TONER_2011
|
||||
@exportProperty ol.source.StamenFlavor.TONER_2011_LABELS
|
||||
@exportProperty ol.source.StamenFlavor.TONER_2011_LINES
|
||||
@exportProperty ol.source.StamenFlavor.TONER_2011_LITE
|
||||
@exportProperty ol.source.StamenFlavor.TONER_BACKGROUND
|
||||
@exportProperty ol.source.StamenFlavor.TONER_HYBRID
|
||||
@exportProperty ol.source.StamenFlavor.TONER_LABELS
|
||||
@exportProperty ol.source.StamenFlavor.TONER_LINES
|
||||
@exportProperty ol.source.StamenFlavor.TONER_LITE
|
||||
|
||||
@exportSymbol ol.source.StamenProvider
|
||||
@exportProperty ol.source.StamenProvider.TERRAIN
|
||||
@exportProperty ol.source.StamenProvider.TONER
|
||||
@exportProperty ol.source.StamenProvider.WATERCOLOR
|
||||
|
||||
@@ -1,61 +1,76 @@
|
||||
// FIXME Configure minZoom when supported by TileGrid
|
||||
|
||||
goog.provide('ol.source.Stamen');
|
||||
goog.provide('ol.source.StamenFlavor');
|
||||
goog.provide('ol.source.StamenProvider');
|
||||
|
||||
goog.require('ol.Attribution');
|
||||
goog.require('ol.source.XYZ');
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
* @type {Object.<string, {extension: string, opaque: boolean}>}
|
||||
*/
|
||||
ol.source.StamenFlavor = {
|
||||
TERRAIN_BACKGROUND: 'background',
|
||||
TERRAIN_LABELS: 'labels',
|
||||
TERRAIN_LINES: 'lines',
|
||||
TONER_2010: '2010',
|
||||
TONER_2011: '2011',
|
||||
TONER_2011_LABELS: '2011-labels',
|
||||
TONER_2011_LINES: '2011-lines',
|
||||
TONER_2011_LITE: '2011-lite',
|
||||
TONER_BACKGROUND: 'background',
|
||||
TONER_HYBRID: 'hybrid',
|
||||
TONER_LABELS: 'labels',
|
||||
TONER_LINES: 'lines',
|
||||
TONER_LITE: 'lite'
|
||||
ol.source.StamenLayerConfig = {
|
||||
'terrain': {
|
||||
extension: 'jpg',
|
||||
opaque: true
|
||||
},
|
||||
'terrain-background': {
|
||||
extension: 'jpg',
|
||||
opaque: true
|
||||
},
|
||||
'terrain-labels': {
|
||||
extension: 'png',
|
||||
opaque: false
|
||||
},
|
||||
'terrain-lines': {
|
||||
extension: 'png',
|
||||
opaque: false
|
||||
},
|
||||
'toner-background': {
|
||||
extension: 'png',
|
||||
opaque: true
|
||||
},
|
||||
'toner': {
|
||||
extension: 'png',
|
||||
opaque: true
|
||||
},
|
||||
'toner-hybrid': {
|
||||
extension: 'png',
|
||||
opaque: false
|
||||
},
|
||||
'toner-labels': {
|
||||
extension: 'png',
|
||||
opaque: false
|
||||
},
|
||||
'toner-lines': {
|
||||
extension: 'png',
|
||||
opaque: false
|
||||
},
|
||||
'toner-lite': {
|
||||
extension: 'png',
|
||||
opaque: true
|
||||
},
|
||||
'watercolor': {
|
||||
extension: 'jpg',
|
||||
opaque: true
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
* @type {Object.<string, {minZoom: number, maxZoom: number}>}
|
||||
*/
|
||||
ol.source.StamenProvider = {
|
||||
TERRAIN: 'terrain',
|
||||
TONER: 'toner',
|
||||
WATERCOLOR: 'watercolor'
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @type {Object.<string, {type: string, minZoom: number, maxZoom: number}>}
|
||||
*/
|
||||
ol.source.StamenProviderConfig = {};
|
||||
ol.source.StamenProviderConfig[ol.source.StamenProvider.TERRAIN] = {
|
||||
type: 'jpg',
|
||||
minZoom: 4,
|
||||
maxZoom: 18
|
||||
};
|
||||
ol.source.StamenProviderConfig[ol.source.StamenProvider.TONER] = {
|
||||
type: 'png',
|
||||
minZoom: 0,
|
||||
maxZoom: 20
|
||||
};
|
||||
ol.source.StamenProviderConfig[ol.source.StamenProvider.WATERCOLOR] = {
|
||||
type: 'jpg',
|
||||
minZoom: 3,
|
||||
maxZoom: 16
|
||||
ol.source.StamenProviderConfig = {
|
||||
'terrain': {
|
||||
minZoom: 4,
|
||||
maxZoom: 18
|
||||
},
|
||||
'toner': {
|
||||
minZoom: 0,
|
||||
maxZoom: 20
|
||||
},
|
||||
'watercolor': {
|
||||
minZoom: 3,
|
||||
maxZoom: 16
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -63,9 +78,9 @@ ol.source.StamenProviderConfig[ol.source.StamenProvider.WATERCOLOR] = {
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.source.XYZ}
|
||||
* @param {ol.source.StamenOptions} stamenOptions Stamen options.
|
||||
* @param {ol.source.StamenOptions} options Options.
|
||||
*/
|
||||
ol.source.Stamen = function(stamenOptions) {
|
||||
ol.source.Stamen = function(options) {
|
||||
|
||||
var attribution = new ol.Attribution(
|
||||
'Map tiles by <a href="http://stamen.com">Stamen Design</a>, ' +
|
||||
@@ -75,18 +90,25 @@ ol.source.Stamen = function(stamenOptions) {
|
||||
'under ' +
|
||||
'<a href="http://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>.');
|
||||
|
||||
var layer = stamenOptions.provider;
|
||||
if (goog.isDef(stamenOptions.flavor)) {
|
||||
layer += '-' + stamenOptions.flavor;
|
||||
}
|
||||
var i = options.layer.indexOf('-');
|
||||
var provider = i == -1 ? options.layer : options.layer.slice(0, i);
|
||||
goog.asserts.assert(provider in ol.source.StamenProviderConfig);
|
||||
var providerConfig = ol.source.StamenProviderConfig[provider];
|
||||
|
||||
var config = ol.source.StamenProviderConfig[stamenOptions.provider];
|
||||
goog.asserts.assert(options.layer in ol.source.StamenLayerConfig);
|
||||
var layerConfig = ol.source.StamenLayerConfig[options.layer];
|
||||
|
||||
var url = goog.isDef(options.url) ? options.url :
|
||||
'http://{a-d}.tile.stamen.com/' + options.layer + '/{z}/{x}/{y}.' +
|
||||
layerConfig.extension;
|
||||
|
||||
goog.base(this, {
|
||||
attributions: [attribution],
|
||||
maxZoom: config.maxZoom,
|
||||
opaque: false,
|
||||
url: 'http://{a-d}.tile.stamen.com/' + layer + '/{z}/{x}/{y}.' + config.type
|
||||
maxZoom: providerConfig.maxZoom,
|
||||
// FIXME uncomment the following when tilegrid supports minZoom
|
||||
//minZoom: providerConfig.minZoom,
|
||||
opaque: layerConfig.opaque,
|
||||
url: url
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user