Skip to content

Commit c90bf14

Browse files
committed
Add contour source and update contour layer styles in map configuration
1 parent aac3fed commit c90bf14

2 files changed

Lines changed: 40 additions & 29 deletions

File tree

vector/maplibregljs/index.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,27 @@
120120
maxzoom: 15,
121121

122122
},
123+
contourSource: {
124+
type: 'vector',
125+
tiles: [
126+
demSource.contourProtocolUrl({
127+
thresholds: {
128+
10: [250, 1000],
129+
11: [100, 500],
130+
12: [50, 100],
131+
13: [50, 100],
132+
14: [20, 100],
133+
15: [10, 100]
134+
},
135+
elevationKey: 'ele',
136+
levelKey: 'level',
137+
contourLayer: 'contours',
138+
buffer: 1,
139+
overzoom: 2,
140+
})
141+
],
142+
maxzoom: 17
143+
},
123144
'opentopomap-tiles': {
124145
'type': 'raster',
125146
'tiles': [

vector/maplibregljs/otm_layers.js

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -90,39 +90,29 @@ const otm_layers = [
9090
"paint": { "hillshade-shadow-color": "#2d3100", "hillshade-method": "igor"}
9191
},
9292
{
93-
"id": "contour-lines",
94-
"type": "line",
95-
"source": "contour-source",
96-
"source-layer": "contours",
97-
"paint": {
98-
"line-color": "rgba(196,87,0,0.7)",
99-
"line-width": ["match", ["get", "level"], 1, 0.6, 0.2],
93+
id: 'contours',
94+
type: 'line',
95+
source: 'contourSource',
96+
'source-layer': 'contours',
97+
paint: {
98+
'line-color': 'rgb(215, 151, 060)',
99+
'line-width': ['match', ['get', 'level'], 1, 1, 0.5],
100100
},
101101
},
102102
{
103-
"id": "contour-labels",
104-
"type": "symbol",
105-
"source": "contour-source",
106-
"source-layer": "contours",
107-
"filter": [
108-
"case",
109-
["<=", ["zoom"], 13],
110-
[">", ["get", "level"], 0],
111-
true // "type don"t care" (return true to show all features)
112-
],
113-
"layout": {
114-
"symbol-placement": "line",
115-
"symbol-spacing": 200,
116-
"text-max-angle": 120,
117-
"text-keep-upright": false,
118-
"text-field": "{ele}",
119-
"text-size": ["step",["zoom"],8,15, ["case",[">", ["get", "level"], 0], 10, 8]],
120-
"text-font": ["Roboto Regular"]
103+
id: 'contour-text',
104+
type: 'symbol',
105+
source: 'contourSource',
106+
'source-layer': 'contours',
107+
paint: {
108+
'text-color': 'rgb(172, 120, 48)',
109+
'text-halo-width': 2,
121110
},
122-
"paint": {
123-
"text-color": "#bc7e55",
124-
"text-halo-color": "rgba(255, 255, 255, 0.5)",
125-
"text-halo-width": 1.5
111+
layout: {
112+
'symbol-placement': 'line-center',
113+
'text-size': 14,
114+
'text-field': ['concat', ['number-format', ['get', 'ele'], {},], 'm'],
115+
'text-font': ['Noto Sans Regular']
126116
}
127117
},
128118
{

0 commit comments

Comments
 (0)