diff --git a/index.html b/index.html index 035afa5..75fbff7 100644 --- a/index.html +++ b/index.html @@ -78,6 +78,10 @@ diff --git a/js/LayersConfig.js b/js/LayersConfig.js index ab4c684..c2c731c 100644 --- a/js/LayersConfig.js +++ b/js/LayersConfig.js @@ -86,19 +86,27 @@ BR.LayersConfig = L.Class.extend({ var propertyOverrides = { 'standard': { 'name': i18next.t('map.layer.osm'), + 'attribution': { + 'html': '© openstreetmap.org, CC-BY-SA 2.0' + }, 'mapUrl': 'https://www.openstreetmap.org/#map={zoom}/{lat}/{lon}' }, 'OpenTopoMap': { 'name': i18next.t('map.layer.topo'), + 'attribution': { + 'html': '© OpenTopoMap, CC-BY-SA 3.0; SRTM' + }, 'mapUrl': 'https://opentopomap.org/#map={zoom}/{lat}/{lon}' }, 'Stamen.Terrain': { 'name': i18next.t('map.layer.stamen-terrain'), + 'attribution': '© Stamen Design, CC BY 3.0', 'mapUrl': 'http://maps.stamen.com/#terrain/{zoom}/{lat}/{lon}' }, 'Esri.WorldImagery': { 'name': i18next.t('map.layer.esri'), 'nameShort': i18next.t('credits.esri-tiles'), + 'attribution': i18next.t('credits.esri-license'), 'mapUrl': 'http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9' }, 'wikimedia-map': { @@ -136,6 +144,9 @@ BR.LayersConfig = L.Class.extend({ 'osm-mapnik-german_style': { 'name': i18next.t('map.layer.osmde'), 'language_code': 'de', + 'attribution': { + 'html': '© openstreetmap.de' + }, 'mapUrl': 'https://www.openstreetmap.de/karte.html?zoom={zoom}&lat={lat}&lon={lon}&layers=B000TF' }, 'osmfr': { @@ -232,16 +243,23 @@ BR.LayersConfig = L.Class.extend({ 'HikeBike.HillShading': { 'name': i18next.t('map.layer.hikebike-hillshading'), 'nameShort': i18next.t('map.hikebike-hillshading'), + 'attribution': '© hikebikemap.org; SRTM3 v2 (NASA)', 'mapUrl': 'http://hikebikemap.org/?zoom={zoom}&lat={lat}&lon={lon}&layer=HikeBikeMap' }, 'Waymarked_Trails-Cycling': { 'name': i18next.t('map.layer.cycling'), 'nameShort': i18next.t('map.cycling'), + 'attribution': { + 'html': '© waymarkedtrails.org, CC-BY-SA 3.0 DE' + }, 'mapUrl': 'http://cycling.waymarkedtrails.org/#?map={zoom}!{lat}!{lon}' }, 'Waymarked_Trails-Hiking': { 'name': i18next.t('map.layer.hiking'), 'nameShort': i18next.t('map.hiking'), + 'attribution': { + 'html': '© waymarkedtrails.org, CC-BY-SA 3.0 DE' + }, 'mapUrl': 'http://hiking.waymarkedtrails.org/#?map={zoom}!{lat}!{lon}' }, 'Waymarked_Trails-MTB': { @@ -382,6 +400,26 @@ BR.LayersConfig = L.Class.extend({ return result; } + function convertAttributionJosm(props) { + var result = ''; + var attr = props.attribution; + + if (attr) { + if (attr.html) { + result = attr.html; + } else if (attr.url && attr.text) { + result = '' + attr.text + ''; + } else if (attr.text) { + result = attr.text; + } + } + if (!result) { + console.warn('No attribution: ' + props.id); + } + + return result; + } + var options = { maxZoom: this._map.getMaxZoom() @@ -389,6 +427,9 @@ BR.LayersConfig = L.Class.extend({ if (props.mapUrl) { options.mapLink = '' + (props.nameShort || props.name) + ''; } + if (props.attribution) { + options.attribution = props.attribution; + } var keyObj = this.getKeyName(url); if (keyObj && BR.keys[keyObj.name]) { @@ -406,7 +447,7 @@ BR.LayersConfig = L.Class.extend({ } else if (props.dataSource === 'LayersCollection') { layer = L.tileLayer(url, L.Util.extend(options, { minZoom: props.minZoom, - maxNativeZoom: props.maxZoom, + maxNativeZoom: props.maxZoom })); if (props.subdomains) { layer.subdomains = props.subdomains; @@ -420,6 +461,7 @@ BR.LayersConfig = L.Class.extend({ minZoom: props.min_zoom, maxNativeZoom: props.max_zoom, subdomains: getSubdomains(josmUrl), + attribution: convertAttributionJosm(props) }); if (props.type && props.type === 'wms') { diff --git a/js/Map.js b/js/Map.js index 6a992c1..c888d5e 100644 --- a/js/Map.js +++ b/js/Map.js @@ -29,6 +29,10 @@ BR.Map = { ' · ' + i18next.t('map.copyright') + '' + ' · ' + i18next.t('map.privacy') + ''); + $('#credits').on('show.bs.modal', function (event) { + BR.Map._renderLayerCredits(layersControl._layers); + }); + new L.Control.PermalinkAttribution().addTo(map); map.attributionControl.setPrefix(false); @@ -44,7 +48,7 @@ BR.Map = { var recent = new L.tileLayer('https://{s}.tiles.mapbox.com/v4/digitalglobe.nal0g75k/{z}/{x}/{y}.png?access_token=' + BR.keys.digitalGlobe, { minZoom: 1, maxZoom: 19, - attribution: i18next.t('credits.digitalglobe-license') + attribution: '© DigitalGlobe (Terms of Use)' }); baseLayers[i18next.t('map.layer.digitalglobe')] = recent; } @@ -89,6 +93,27 @@ BR.Map = { map: map, layersControl: layersControl }; - } + }, + _renderLayerCredits: function (layers) { + var dl = document.getElementById('credits-maps'); + var i, obj, dt, dd, attribution; + + L.DomUtil.empty(dl); + + for (i = 0; i < layers.length; i++) { + obj = layers[i]; + attribution = obj.layer.options.attribution; + + if (attribution) { + dt = document.createElement('dt'); + dt.innerHTML = obj.name; + dd = document.createElement('dd'); + dd.innerHTML = obj.layer.options.attribution; + + dl.appendChild(dt); + dl.appendChild(dd); + } + } + } }; diff --git a/locales/en.json b/locales/en.json index d420af6..43d0c78 100644 --- a/locales/en.json +++ b/locales/en.json @@ -14,21 +14,12 @@ "credits": { "brouter": "BRouter", "brouter-license": "BRouter © Arndt Brenschede", - "cycling-hiking-tiles": "Cycling & Hiking tiles", - "digitalglobe-license": "© DigitalGlobe (Terms of Use)", "esri-license": "World Imagery © Esri, sources: Esri, DigitalGlobe, Earthstar Geographics, CNES/Airbus DS, GeoEye, USDA FSA, USGS, Getmapping, Aerogrid, IGN, IGP, and the GIS User Community", "esri-tiles": "Esri World Imagery", "map-data": "Map data", + "map-tiles": "Map tiles", "nominatim": "Search by Nominatim", - "opencyclemap-outdoors-tiles": "OpenCycleMap & Outdoors tiles", - "openstreetmap": "© OpenStreetMap contributors under ODbL", - "opentopomap-license": "© OpenTopoMap under CC-BY-SA SRTM", - "opentopomap-tiles": "OpenTopoMap tiles", - "osm-license": "openstreetmap.org under CC-BY-SA 2.0", - "osm-tiles": "OpenStreetMap tiles", - "osmde-tiles": "OpenStreetMap.de tiles", - "thunderforest-license": "© Thunderforest under CC-BY-SA 2.0", - "waymarked-license": "© Waymarked Trails under CC-BY-SA 3.0 DE" + "openstreetmap": "© OpenStreetMap contributors under ODbL" }, "footer": { "ascend": "Ascend (Plain ascend)",