diff --git a/plugins/basemap-openstreetmap.user.js b/plugins/basemap-openstreetmap.user.js index 701434db..779d0105 100644 --- a/plugins/basemap-openstreetmap.user.js +++ b/plugins/basemap-openstreetmap.user.js @@ -24,18 +24,27 @@ // use own namespace for plugin -window.plugin.mapTileOpenStreetMap = function() {}; +window.plugin.mapTileOpenStreetMap = { + addLayer: function() { + // OpenStreetMap tiles - we shouldn't use these by default - https://wiki.openstreetmap.org/wiki/Tile_usage_policy + // "Heavy use (e.g. distributing an app that uses tiles from openstreetmap.org) is forbidden without prior permission from the System Administrators" -window.plugin.mapTileOpenStreetMap.addLayer = function() { + var osmOpt = { + attribution: 'Map data © OpenStreetMap contributors', + maxNativeZoom: 18, + maxZoom: 21, + }; - //OpenStreetMap tiles - we shouldn't use these by default - https://wiki.openstreetmap.org/wiki/Tile_usage_policy - // "Heavy use (e.g. distributing an app that uses tiles from openstreetmap.org) is forbidden without prior permission from the System Administrators" + var layers = { + 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png': 'OpenStreetMap', + 'http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png': 'Humanitarian', + }; - osmAttribution = 'Map data © OpenStreetMap contributors'; - var osmOpt = {attribution: osmAttribution, maxNativeZoom: 18, maxZoom: 21}; - var osm = new L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', osmOpt); - - layerChooser.addBaseLayer(osm, "OpenStreetMap"); + for(var url in layers) { + var layer = new L.TileLayer(url, osmOpt); + layerChooser.addBaseLayer(layer, layers[url]); + } + }, }; var setup = window.plugin.mapTileOpenStreetMap.addLayer;