add contour-label

This commit is contained in:
Miko 2025-01-04 01:00:04 +01:00
parent 43f86e9a66
commit 1bfeac2e01
2 changed files with 21 additions and 24 deletions

View file

@ -26,7 +26,7 @@ class MaplibreContourControl {
this.controlContainer.classList.add("maplibre-ctrl-contour-active"); this.controlContainer.classList.add("maplibre-ctrl-contour-active");
this.contourButton.title = "Disable Contours"; this.contourButton.title = "Disable Contours";
} else { } else {
this.contourButton.title = "Ensable Contours"; this.contourButton.title = "Enable Contours";
} }
}); });
}); });

View file

@ -11,6 +11,7 @@
<script src="{{public_url}}maplibre-gl-inspect.js{{&key_query}}"></script> <script src="{{public_url}}maplibre-gl-inspect.js{{&key_query}}"></script>
<script src="{{public_url}}elevation-control.js{{&key_query}}"></script> <script src="{{public_url}}elevation-control.js{{&key_query}}"></script>
<script src="{{public_url}}contour-control.js{{&key_query}}"></script> <script src="{{public_url}}contour-control.js{{&key_query}}"></script>
<script src="{{public_url}}elevation-control.js{{&key_query}}"></script>
<style> <style>
body {background:#fff;color:#333;font-family:Arial, sans-serif;} body {background:#fff;color:#333;font-family:Arial, sans-serif;}
{{^is_terrain}} {{^is_terrain}}
@ -94,7 +95,7 @@
"tiles": [ baseUrl + "/data/{{id}}/contour/{z}/{x}/{y}" ], "tiles": [ baseUrl + "/data/{{id}}/contour/{z}/{x}/{y}" ],
} }
}, },
"glyphs": "local://fonts/{fontstack}/{range}.pbf", "glyphs": "/fonts/{fontstack}/{range}.pbf",
"terrain": { "terrain": {
"source": "terrain" "source": "terrain"
}, },
@ -127,24 +128,20 @@
} }
}, },
{ {
"id": 'contour-label', "id": "contour-label",
"type": 'symbol', "type": "symbol",
"source": 'contour', "source": "contour",
"source-layer": 'contours', "source-layer": "contours",
"filter": ['>', ['get', 'level'], 0], "filter": [">", ["get", "ele"], 0 ],
"paint": { "paint": {
'text-halo-color': 'white', "text-halo-color": "white",
'text-halo-width': 1 "text-halo-width": 1
}, },
"layout": { "layout": {
'symbol-placement': 'line', "symbol-placement": "line",
'text-size': 10, "text-size": 10,
'text-field': [ "text-field": "{ele}",
'concat', "text-font": ["Noto Sans Bold"]
['number-format', ['get', 'ele'], {}],
'\''
],
'text-font': ['Noto Sans Bold']
} }
} }
] ]
@ -179,11 +176,11 @@
}) })
); );
//map.addControl( map.addControl(
// new ElevationInfo({ new ElevationInfoControl({
// url: baseUrl + "/data/{{id}}/elvation/{z}/{x}/{y}" url: baseUrl + "/data/{{id}}/elvation/{z}/{x}/{y}"
// }) })
//); );
{{/is_terrain}} {{/is_terrain}}
{{^is_terrain}} {{^is_terrain}}