Skip to content

Commit

Permalink
Configure hillshading layer
Browse files Browse the repository at this point in the history
- full attribution
- i18n key
- paint property defaults as template
  • Loading branch information
nrenner committed Jun 15, 2022
1 parent 8c8582a commit ad68d00
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 11 deletions.
6 changes: 2 additions & 4 deletions js/LayersConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,7 @@ BR.LayersConfig = L.Class.extend({
return new leafletOsmNotes();
},

createMvtLayer: function (props) {
const options = {};

createMvtLayer: function (props, options) {
if (props.url in BR.layerIndex) {
// url is key to style in local layers bundle (file name without '.json'),
// suggested file naming convention: `<layer id>-style.json`
Expand Down Expand Up @@ -346,7 +344,7 @@ BR.LayersConfig = L.Class.extend({
} else if (props.dataSource === 'OpenStreetMapNotesAPI') {
layer = this.createOpenStreetMapNotesLayer();
} else if (props.type === 'mvt') {
layer = this.createMvtLayer(props);
layer = this.createMvtLayer(props, options);
} else {
// JOSM
var josmUrl = url;
Expand Down
4 changes: 4 additions & 0 deletions js/util/MaplibreGlLazyLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ BR.MaplibreGlLazyLoader = L.Layer.extend({

_addGlLayer: function () {
this.glLayer = L.maplibreGL(this.options);
// see LayersConfig.createLayer
this.glLayer.getAttribution = function () {
return this.options.mapLink;
};
this._map.addLayer(this.glLayer);

this._updateZIndex();
Expand Down
3 changes: 3 additions & 0 deletions layers/config/overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,5 +248,8 @@ BR.confLayers.getPropertyOverrides = function() {
'nameShort': 'CyclOSM',
'mapUrl': 'https://www.cyclosm.org/#map={zoom}/{lat}/{lon}/cyclosm'
},
'terrarium-hillshading': {
'name': i18next.t('map.layer.hillshading')
}
};
};
8 changes: 7 additions & 1 deletion layers/mvt/terrarium-hillshading-style.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@
{
"id": "hillshading",
"source": "dem",
"type": "hillshade"
"type": "hillshade",
"paint": {
"hillshade-exaggeration": 0.5,
"hillshade-shadow-color": "#000000",
"hillshade-highlight-color": "#FFFFFF",
"hillshade-accent-color": "rgba(0, 0, 0, 1)"
}
}
]
}
9 changes: 3 additions & 6 deletions layers/mvt/terrarium-hillshading.geojson
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
{
"geometry": null,
"properties": {
"attribution": {
"text": "Terrain Tiles from AWS",
"url": "https://registry.opendata.aws/terrain-tiles/"
},
"id": "terrarium-hillshading",
"name": "Hillshading",
"overlay": true,
"type": "mvt",
"url": "terrarium-hillshading-style"
"url": "terrarium-hillshading-style",
"mapUrl": "https://registry.opendata.aws/terrain-tiles/",
"attribution": "<a target=\"_blank\" rel=\"noopener\" href=\"https://registry.opendata.aws/terrain-tiles/\">Terrain Tiles at Registry of Open Data on AWS</a>: <ul><li>ArcticDEM terrain data DEM(s) were created from DigitalGlobe, Inc., imagery and funded under National Science Foundation awards 1043681, 1559691, and 1542736 </li><li> Australia terrain data © Commonwealth of Australia (Geoscience Australia) 2017 </li><li> Austria terrain data © offene Daten Österreichs – Digitales Geländemodell (DGM) Österreich </li><li> Canada terrain data contains information licensed under the Open Government Licence – Canada </li><li> Europe terrain data produced using Copernicus data and information funded by the European Union - EU-DEM layers </li><li> Global ETOPO1 terrain data U.S. National Oceanic and Atmospheric Administration</li><li> Mexico terrain data source: INEGI, Continental relief, 2016 </li><li> New Zealand terrain data Copyright 2011 Crown copyright (c) Land Information New Zealand and the New Zealand Government (All rights reserved) </li><li> Norway terrain data © Kartverket </li><li> United Kingdom terrain data © Environment Agency copyright and/or database right 2015. All rights reserved </li><li> United States 3DEP (formerly NED) and global GMTED2010 and SRTM terrain data courtesy of the U.S. Geological Survey.</li></ul>"
},
"type": "Feature"
}
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
"esri": "Esri World Imagery",
"hikebike-hillshading": "Hillshading (Hike & Bike Map)",
"hiking": "Hiking (Waymarked Trails)",
"hillshading": "Hillshading",
"osm": "OpenStreetMap",
"osmde": "OpenStreetMap.de",
"outdoors": "Outdoors (Thunderforest)",
Expand Down

0 comments on commit ad68d00

Please sign in to comment.