Generate layer credits dynamically (#146)
This commit is contained in:
parent
692d67dee1
commit
bea7af0084
4 changed files with 78 additions and 49 deletions
41
index.html
41
index.html
|
|
@ -78,6 +78,10 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt data-i18n="credits.brouter">BRouter</dt>
|
||||||
|
<dd data-i18n="[html]credits.brouter-license">
|
||||||
|
<a target="_blank" href="http://brouter.de/brouter">BRouter</a> © Arndt Brenschede
|
||||||
|
</dd>
|
||||||
<dt data-i18n="credits.map-data">Map data</dt>
|
<dt data-i18n="credits.map-data">Map data</dt>
|
||||||
<dd data-i18n="[html]credits.openstreetmap">
|
<dd data-i18n="[html]credits.openstreetmap">
|
||||||
© <a target="_blank" href="https://www.openstreetmap.org/copyright" >OpenStreetMap contributors</a>
|
© <a target="_blank" href="https://www.openstreetmap.org/copyright" >OpenStreetMap contributors</a>
|
||||||
|
|
@ -86,42 +90,9 @@
|
||||||
<dd data-i18n="[html]credits.nominatim">
|
<dd data-i18n="[html]credits.nominatim">
|
||||||
Search by <a href="https://wiki.openstreetmap.org/wiki/Nominatim" target="_blank">Nominatim</a>
|
Search by <a href="https://wiki.openstreetmap.org/wiki/Nominatim" target="_blank">Nominatim</a>
|
||||||
</dd>
|
</dd>
|
||||||
<dt data-i18n="credits.osm-tiles">OpenStreetMap tiles</dt>
|
|
||||||
<dd data-i18n="[html]credits.osm-license">
|
|
||||||
<a target="_blank" href="https://www.openstreetmap.org/copyright">openstreetmap.org</a>
|
|
||||||
under <a target="_blank" href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA 2.0</a>
|
|
||||||
</dd>
|
|
||||||
<dt data-i18n="credits.osmde-tiles">OpenStreetMap.de tiles</dt>
|
|
||||||
<dd>
|
|
||||||
<a target="_blank" href="https://openstreetmap.de/karte.html">openstreetmap.de</a>
|
|
||||||
</dd>
|
|
||||||
<dt data-i18n="credits.opentopomap-tiles">OpenTopoMap tiles</dt>
|
|
||||||
<dd data-i18n="[html]credits.opentopomap-license">
|
|
||||||
© <a target="_blank" href="https://opentopomap.org">OpenTopoMap</a>
|
|
||||||
under <a target="_blank" href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>
|
|
||||||
<a target="_blank" href="http://viewfinderpanoramas.org">SRTM</a>
|
|
||||||
</dd>
|
|
||||||
<dt data-i18n="credits.opencyclemap-outdoors-tiles">OpenCycleMap & Outdoors tiles</dt>
|
|
||||||
<dd data-i18n="[html]credits.thunderforest-license">
|
|
||||||
© <a target="_blank" href="https://www.thunderforest.com">Thunderforest</a>
|
|
||||||
under <a target="_blank" href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA 2.0</a>
|
|
||||||
</dd>
|
|
||||||
<dt data-i18n="credits.esri-tiles">Esri World Imagery</dt>
|
|
||||||
<dd data-i18n="[html]credits.esri-license">
|
|
||||||
<a target="_blank" href="http://goto.arcgisonline.com/maps/World_Imagery">World Imagery</a>
|
|
||||||
© <a target="_blank" href="https://www.esri.com/">Esri</a>, sources:
|
|
||||||
Esri, DigitalGlobe, Earthstar Geographics, CNES/Airbus DS, GeoEye, USDA FSA, USGS, Getmapping, Aerogrid, IGN, IGP, and the GIS User Community
|
|
||||||
</dd>
|
|
||||||
<dt data-i18n="credits.cycling-hiking-tiles">Cycling & Hiking tiles</dt>
|
|
||||||
<dd data-i18n="[html]credits.waymarked-license">
|
|
||||||
© <a target="_blank" href="https://cycling.waymarkedtrails.org">Waymarked Trails</a>
|
|
||||||
under <a target="_blank" href="https://creativecommons.org/licenses/by-sa/3.0/de/deed.en">CC-BY-SA 3.0 DE</a>
|
|
||||||
</dd>
|
|
||||||
<dt data-i18n="credits.brouter">BRouter</dt>
|
|
||||||
<dd data-i18n="[html]credits.brouter-license">
|
|
||||||
<a target="_blank" href="http://brouter.de/brouter">BRouter</a> © Arndt Brenschede
|
|
||||||
</dd>
|
|
||||||
</dl>
|
</dl>
|
||||||
|
<h5 data-i18n="credits.map-tiles">Map tiles</h5>
|
||||||
|
<dl id="credits-maps"></dl>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -86,19 +86,27 @@ BR.LayersConfig = L.Class.extend({
|
||||||
var propertyOverrides = {
|
var propertyOverrides = {
|
||||||
'standard': {
|
'standard': {
|
||||||
'name': i18next.t('map.layer.osm'),
|
'name': i18next.t('map.layer.osm'),
|
||||||
|
'attribution': {
|
||||||
|
'html': '© <a target="_blank" href="https://www.openstreetmap.org/copyright">openstreetmap.org</a>, <a target="_blank" href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA 2.0</a>'
|
||||||
|
},
|
||||||
'mapUrl': 'https://www.openstreetmap.org/#map={zoom}/{lat}/{lon}'
|
'mapUrl': 'https://www.openstreetmap.org/#map={zoom}/{lat}/{lon}'
|
||||||
},
|
},
|
||||||
'OpenTopoMap': {
|
'OpenTopoMap': {
|
||||||
'name': i18next.t('map.layer.topo'),
|
'name': i18next.t('map.layer.topo'),
|
||||||
|
'attribution': {
|
||||||
|
'html': '© <a target="_blank" href="https://opentopomap.org/about#verwendung">OpenTopoMap</a>, <a target="_blank" href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA 3.0</a>; <a target="_blank" href="http://viewfinderpanoramas.org">SRTM</a>'
|
||||||
|
},
|
||||||
'mapUrl': 'https://opentopomap.org/#map={zoom}/{lat}/{lon}'
|
'mapUrl': 'https://opentopomap.org/#map={zoom}/{lat}/{lon}'
|
||||||
},
|
},
|
||||||
'Stamen.Terrain': {
|
'Stamen.Terrain': {
|
||||||
'name': i18next.t('map.layer.stamen-terrain'),
|
'name': i18next.t('map.layer.stamen-terrain'),
|
||||||
|
'attribution': '© <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>',
|
||||||
'mapUrl': 'http://maps.stamen.com/#terrain/{zoom}/{lat}/{lon}'
|
'mapUrl': 'http://maps.stamen.com/#terrain/{zoom}/{lat}/{lon}'
|
||||||
},
|
},
|
||||||
'Esri.WorldImagery': {
|
'Esri.WorldImagery': {
|
||||||
'name': i18next.t('map.layer.esri'),
|
'name': i18next.t('map.layer.esri'),
|
||||||
'nameShort': i18next.t('credits.esri-tiles'),
|
'nameShort': i18next.t('credits.esri-tiles'),
|
||||||
|
'attribution': i18next.t('credits.esri-license'),
|
||||||
'mapUrl': 'http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'
|
'mapUrl': 'http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'
|
||||||
},
|
},
|
||||||
'wikimedia-map': {
|
'wikimedia-map': {
|
||||||
|
|
@ -136,6 +144,9 @@ BR.LayersConfig = L.Class.extend({
|
||||||
'osm-mapnik-german_style': {
|
'osm-mapnik-german_style': {
|
||||||
'name': i18next.t('map.layer.osmde'),
|
'name': i18next.t('map.layer.osmde'),
|
||||||
'language_code': 'de',
|
'language_code': 'de',
|
||||||
|
'attribution': {
|
||||||
|
'html': '© <a target="_blank" href="https://openstreetmap.de/karte.html">openstreetmap.de</a>'
|
||||||
|
},
|
||||||
'mapUrl': 'https://www.openstreetmap.de/karte.html?zoom={zoom}&lat={lat}&lon={lon}&layers=B000TF'
|
'mapUrl': 'https://www.openstreetmap.de/karte.html?zoom={zoom}&lat={lat}&lon={lon}&layers=B000TF'
|
||||||
},
|
},
|
||||||
'osmfr': {
|
'osmfr': {
|
||||||
|
|
@ -232,16 +243,23 @@ BR.LayersConfig = L.Class.extend({
|
||||||
'HikeBike.HillShading': {
|
'HikeBike.HillShading': {
|
||||||
'name': i18next.t('map.layer.hikebike-hillshading'),
|
'name': i18next.t('map.layer.hikebike-hillshading'),
|
||||||
'nameShort': i18next.t('map.hikebike-hillshading'),
|
'nameShort': i18next.t('map.hikebike-hillshading'),
|
||||||
|
'attribution': '© <a target="_blank" href="http://hikebikemap.org">hikebikemap.org</a>; SRTM3 v2 (<a target="_blank" href="http://www2.jpl.nasa.gov/srtm/">NASA</a>)',
|
||||||
'mapUrl': 'http://hikebikemap.org/?zoom={zoom}&lat={lat}&lon={lon}&layer=HikeBikeMap'
|
'mapUrl': 'http://hikebikemap.org/?zoom={zoom}&lat={lat}&lon={lon}&layer=HikeBikeMap'
|
||||||
},
|
},
|
||||||
'Waymarked_Trails-Cycling': {
|
'Waymarked_Trails-Cycling': {
|
||||||
'name': i18next.t('map.layer.cycling'),
|
'name': i18next.t('map.layer.cycling'),
|
||||||
'nameShort': i18next.t('map.cycling'),
|
'nameShort': i18next.t('map.cycling'),
|
||||||
|
'attribution': {
|
||||||
|
'html': '© <a target="_blank" href="https://cycling.waymarkedtrails.org/en/help/legal">waymarkedtrails.org</a>, <a target="_blank" href="https://creativecommons.org/licenses/by-sa/3.0/de/deed.en">CC-BY-SA 3.0 DE</a>'
|
||||||
|
},
|
||||||
'mapUrl': 'http://cycling.waymarkedtrails.org/#?map={zoom}!{lat}!{lon}'
|
'mapUrl': 'http://cycling.waymarkedtrails.org/#?map={zoom}!{lat}!{lon}'
|
||||||
},
|
},
|
||||||
'Waymarked_Trails-Hiking': {
|
'Waymarked_Trails-Hiking': {
|
||||||
'name': i18next.t('map.layer.hiking'),
|
'name': i18next.t('map.layer.hiking'),
|
||||||
'nameShort': i18next.t('map.hiking'),
|
'nameShort': i18next.t('map.hiking'),
|
||||||
|
'attribution': {
|
||||||
|
'html': '© <a target="_blank" href="https://hiking.waymarkedtrails.org/en/help/legal">waymarkedtrails.org</a>, <a target="_blank" href="https://creativecommons.org/licenses/by-sa/3.0/de/deed.en">CC-BY-SA 3.0 DE</a>'
|
||||||
|
},
|
||||||
'mapUrl': 'http://hiking.waymarkedtrails.org/#?map={zoom}!{lat}!{lon}'
|
'mapUrl': 'http://hiking.waymarkedtrails.org/#?map={zoom}!{lat}!{lon}'
|
||||||
},
|
},
|
||||||
'Waymarked_Trails-MTB': {
|
'Waymarked_Trails-MTB': {
|
||||||
|
|
@ -382,6 +400,26 @@ BR.LayersConfig = L.Class.extend({
|
||||||
return result;
|
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 = '<a href="' + attr.url + '" target="_blank" rel="noopener">' + attr.text + '</a>';
|
||||||
|
} else if (attr.text) {
|
||||||
|
result = attr.text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!result) {
|
||||||
|
console.warn('No attribution: ' + props.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
maxZoom: this._map.getMaxZoom()
|
maxZoom: this._map.getMaxZoom()
|
||||||
|
|
@ -389,6 +427,9 @@ BR.LayersConfig = L.Class.extend({
|
||||||
if (props.mapUrl) {
|
if (props.mapUrl) {
|
||||||
options.mapLink = '<a target="_blank" href="' + props.mapUrl + '">' + (props.nameShort || props.name) + '</a>';
|
options.mapLink = '<a target="_blank" href="' + props.mapUrl + '">' + (props.nameShort || props.name) + '</a>';
|
||||||
}
|
}
|
||||||
|
if (props.attribution) {
|
||||||
|
options.attribution = props.attribution;
|
||||||
|
}
|
||||||
|
|
||||||
var keyObj = this.getKeyName(url);
|
var keyObj = this.getKeyName(url);
|
||||||
if (keyObj && BR.keys[keyObj.name]) {
|
if (keyObj && BR.keys[keyObj.name]) {
|
||||||
|
|
@ -406,7 +447,7 @@ BR.LayersConfig = L.Class.extend({
|
||||||
} else if (props.dataSource === 'LayersCollection') {
|
} else if (props.dataSource === 'LayersCollection') {
|
||||||
layer = L.tileLayer(url, L.Util.extend(options, {
|
layer = L.tileLayer(url, L.Util.extend(options, {
|
||||||
minZoom: props.minZoom,
|
minZoom: props.minZoom,
|
||||||
maxNativeZoom: props.maxZoom,
|
maxNativeZoom: props.maxZoom
|
||||||
}));
|
}));
|
||||||
if (props.subdomains) {
|
if (props.subdomains) {
|
||||||
layer.subdomains = props.subdomains;
|
layer.subdomains = props.subdomains;
|
||||||
|
|
@ -420,6 +461,7 @@ BR.LayersConfig = L.Class.extend({
|
||||||
minZoom: props.min_zoom,
|
minZoom: props.min_zoom,
|
||||||
maxNativeZoom: props.max_zoom,
|
maxNativeZoom: props.max_zoom,
|
||||||
subdomains: getSubdomains(josmUrl),
|
subdomains: getSubdomains(josmUrl),
|
||||||
|
attribution: convertAttributionJosm(props)
|
||||||
});
|
});
|
||||||
|
|
||||||
if (props.type && props.type === 'wms') {
|
if (props.type && props.type === 'wms') {
|
||||||
|
|
|
||||||
29
js/Map.js
29
js/Map.js
|
|
@ -29,6 +29,10 @@ BR.Map = {
|
||||||
' · <a href="" data-toggle="modal" data-target="#credits">' + i18next.t('map.copyright') + '</a>' +
|
' · <a href="" data-toggle="modal" data-target="#credits">' + i18next.t('map.copyright') + '</a>' +
|
||||||
' · <a target="_blank" href="http://brouter.de/privacypolicy.html">' + i18next.t('map.privacy') + '</a>');
|
' · <a target="_blank" href="http://brouter.de/privacypolicy.html">' + i18next.t('map.privacy') + '</a>');
|
||||||
|
|
||||||
|
$('#credits').on('show.bs.modal', function (event) {
|
||||||
|
BR.Map._renderLayerCredits(layersControl._layers);
|
||||||
|
});
|
||||||
|
|
||||||
new L.Control.PermalinkAttribution().addTo(map);
|
new L.Control.PermalinkAttribution().addTo(map);
|
||||||
map.attributionControl.setPrefix(false);
|
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, {
|
var recent = new L.tileLayer('https://{s}.tiles.mapbox.com/v4/digitalglobe.nal0g75k/{z}/{x}/{y}.png?access_token=' + BR.keys.digitalGlobe, {
|
||||||
minZoom: 1,
|
minZoom: 1,
|
||||||
maxZoom: 19,
|
maxZoom: 19,
|
||||||
attribution: i18next.t('credits.digitalglobe-license')
|
attribution: '© <a href=\"https://www.digitalglobe.com/platforms/mapsapi\">DigitalGlobe</a> (<a href=\"https://bit.ly/mapsapiview\">Terms of Use</a>)'
|
||||||
});
|
});
|
||||||
baseLayers[i18next.t('map.layer.digitalglobe')] = recent;
|
baseLayers[i18next.t('map.layer.digitalglobe')] = recent;
|
||||||
}
|
}
|
||||||
|
|
@ -89,6 +93,27 @@ BR.Map = {
|
||||||
map: map,
|
map: map,
|
||||||
layersControl: layersControl
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -14,21 +14,12 @@
|
||||||
"credits": {
|
"credits": {
|
||||||
"brouter": "BRouter",
|
"brouter": "BRouter",
|
||||||
"brouter-license": "<a target=\"_blank\" href=\"http://brouter.de/brouter\">BRouter</a> © Arndt Brenschede",
|
"brouter-license": "<a target=\"_blank\" href=\"http://brouter.de/brouter\">BRouter</a> © Arndt Brenschede",
|
||||||
"cycling-hiking-tiles": "Cycling & Hiking tiles",
|
|
||||||
"digitalglobe-license": "© <a href=\"https://www.digitalglobe.com/platforms/mapsapi\">DigitalGlobe</a> (<a href=\"https://bit.ly/mapsapiview\">Terms of Use</a>)",
|
|
||||||
"esri-license": "<a target=\"_blank\" href=\"http://goto.arcgisonline.com/maps/World_Imagery\">World Imagery</a> © <a target=\"_blank\" href=\"https://www.esri.com/\">Esri</a>, sources: Esri, DigitalGlobe, Earthstar Geographics, CNES/Airbus DS, GeoEye, USDA FSA, USGS, Getmapping, Aerogrid, IGN, IGP, and the GIS User Community",
|
"esri-license": "<a target=\"_blank\" href=\"http://goto.arcgisonline.com/maps/World_Imagery\">World Imagery</a> © <a target=\"_blank\" href=\"https://www.esri.com/\">Esri</a>, 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",
|
"esri-tiles": "Esri World Imagery",
|
||||||
"map-data": "Map data",
|
"map-data": "Map data",
|
||||||
|
"map-tiles": "Map tiles",
|
||||||
"nominatim": "Search by <a href=\"https://wiki.openstreetmap.org/wiki/Nominatim\" target=\"_blank\" data-i18n=\"credits.nominatim\">Nominatim</a>",
|
"nominatim": "Search by <a href=\"https://wiki.openstreetmap.org/wiki/Nominatim\" target=\"_blank\" data-i18n=\"credits.nominatim\">Nominatim</a>",
|
||||||
"opencyclemap-outdoors-tiles": "OpenCycleMap & Outdoors tiles",
|
"openstreetmap": "© <a target=\"_blank\" href=\"https://www.openstreetmap.org/copyright\" >OpenStreetMap contributors</a> under <a target=\"_blank\" href=\"https://opendatacommons.org/licenses/odbl/\" >ODbL</a>"
|
||||||
"openstreetmap": "© <a target=\"_blank\" href=\"https://www.openstreetmap.org/copyright\" >OpenStreetMap contributors</a> under <a target=\"_blank\" href=\"https://opendatacommons.org/licenses/odbl/\" >ODbL</a>",
|
|
||||||
"opentopomap-license": "© <a target=\"_blank\" href=\"https://opentopomap.org\">OpenTopoMap</a> under <a target=\"_blank\" href=\"https://creativecommons.org/licenses/by-sa/3.0/\">CC-BY-SA</a> <a target=\"_blank\" href=\"http://viewfinderpanoramas.org\">SRTM</a>",
|
|
||||||
"opentopomap-tiles": "OpenTopoMap tiles",
|
|
||||||
"osm-license": "<a target=\"_blank\" href=\"https://www.openstreetmap.org/copyright\">openstreetmap.org</a> under <a target=\"_blank\" href=\"https://creativecommons.org/licenses/by-sa/2.0/\">CC-BY-SA 2.0</a>",
|
|
||||||
"osm-tiles": "OpenStreetMap tiles",
|
|
||||||
"osmde-tiles": "OpenStreetMap.de tiles",
|
|
||||||
"thunderforest-license": "© <a target=\"_blank\" href=\"https://www.thunderforest.com\">Thunderforest</a> under <a target=\"_blank\" href=\"https://creativecommons.org/licenses/by-sa/2.0/\">CC-BY-SA 2.0</a>",
|
|
||||||
"waymarked-license": "© <a target=\"_blank\" href=\"https://cycling.waymarkedtrails.org\">Waymarked Trails</a> under <a target=\"_blank\" href=\"https://creativecommons.org/licenses/by-sa/3.0/de/deed.en\">CC-BY-SA 3.0 DE</a>"
|
|
||||||
},
|
},
|
||||||
"footer": {
|
"footer": {
|
||||||
"ascend": "Ascend (Plain ascend)",
|
"ascend": "Ascend (Plain ascend)",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue