basemap-staman: changed from using their library to direct tile url references
this allows us to switch http/https as required, and fixes a bug with remembering default layers on IITC startup
This commit is contained in:
parent
3f15535f48
commit
f92accdd89
@ -2,7 +2,7 @@
|
|||||||
// @id iitc-plugin-basemap-stamen@jonatkins
|
// @id iitc-plugin-basemap-stamen@jonatkins
|
||||||
// @name IITC plugin: Map layers from stamen.com
|
// @name IITC plugin: Map layers from stamen.com
|
||||||
// @category Map Tiles
|
// @category Map Tiles
|
||||||
// @version 0.1.0.@@DATETIMEVERSION@@
|
// @version 0.2.0.@@DATETIMEVERSION@@
|
||||||
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||||
// @updateURL @@UPDATEURL@@
|
// @updateURL @@UPDATEURL@@
|
||||||
// @downloadURL @@DOWNLOADURL@@
|
// @downloadURL @@DOWNLOADURL@@
|
||||||
@ -22,34 +22,45 @@
|
|||||||
// use own namespace for plugin
|
// use own namespace for plugin
|
||||||
window.plugin.mapTileStamen = function() {};
|
window.plugin.mapTileStamen = function() {};
|
||||||
|
|
||||||
window.plugin.mapTileStamen.setup = function() {
|
|
||||||
|
|
||||||
load('http://maps.stamen.com/js/tile.stamen.js?v1.2.3').thenRun(window.plugin.mapTileStamen.addLayer);
|
|
||||||
}
|
|
||||||
|
|
||||||
window.plugin.mapTileStamen.addLayer = function() {
|
window.plugin.mapTileStamen.addLayer = function() {
|
||||||
|
|
||||||
var types = {
|
var types = {
|
||||||
'toner': 'Toner',
|
'toner': [ 'Toner', 'png', 0, 20 ],
|
||||||
// 'toner-hybrid': 'Toner Hybrid', // transparent layer. could be usefun over satelliate imagery or similar
|
// 'toner-hybrid': [ ' Toner Hybrid', 'png', 0, 20 ], // transparent layer. could be usefun over satelliate imagery or similar
|
||||||
// 'toner-labels': 'Toner Labels', // transparent layer. could be usefun over satelliate imagery or similar
|
// 'toner-labels': [ 'Toner Labels', 'png', 0, 20 ], // transparent layer. could be usefun over satelliate imagery or similar
|
||||||
// 'toner-lines': 'Toner Lines', // transparent layer. could be usefun over satelliate imagery or similar
|
// 'toner-lines': [ 'Toner Lines', 'png', 0, 20 ], // transparent layer. could be usefun over satelliate imagery or similar
|
||||||
'toner-background': 'Toner Background',
|
'toner-background': [ 'Toner Background', 'png', 0, 20 ],
|
||||||
'toner-lite': 'Toner Lite',
|
'toner-lite': [ 'Toner Lite', 'png', 0, 20 ],
|
||||||
'watercolor': 'Watercolor',
|
'watercolor': [ 'Watercolor', 'jpg', 1, 16 ],
|
||||||
};
|
};
|
||||||
|
|
||||||
for (var type in types) {
|
var baseUrl = window.location.protocol == 'https:' ? 'https://stamen-tiles-{s}.a.ssl.fastly.net/' : 'http://{s}.tile.stamen.com/';
|
||||||
var name = types[type];
|
|
||||||
|
|
||||||
var layer = new L.StamenTileLayer(type);
|
|
||||||
|
|
||||||
layerChooser.addBaseLayer(layer,'Stamen '+name);
|
for (var layer in types) {
|
||||||
|
var info = types[layer];
|
||||||
|
|
||||||
|
var name = info[0];
|
||||||
|
var type = info[1];
|
||||||
|
var minZoom = info[2];
|
||||||
|
var maxZoom = info[3];
|
||||||
|
|
||||||
|
var mapLayer = new L.TileLayer (baseUrl+'{layer}/{z}/{x}/{y}.{type}', {
|
||||||
|
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>.',
|
||||||
|
subdomains: 'abcd',
|
||||||
|
layer: layer,
|
||||||
|
type: type,
|
||||||
|
minZoom: minZoom,
|
||||||
|
maxZoom: maxZoom
|
||||||
|
});
|
||||||
|
|
||||||
|
layerChooser.addBaseLayer(mapLayer,'Stamen '+name);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var setup = window.plugin.mapTileStamen.setup;
|
var setup = window.plugin.mapTileStamen.addLayer;
|
||||||
|
|
||||||
// PLUGIN END //////////////////////////////////////////////////////////
|
// PLUGIN END //////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user