tileserver-gl-light 4.13.3 → 5.1.0-pre.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,9 +14,41 @@ on:
14
14
  required: true
15
15
 
16
16
  jobs:
17
+ release-check:
18
+ name: Check if version is published
19
+ runs-on: ubuntu-latest
20
+ defaults:
21
+ run:
22
+ shell: bash
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+
26
+ - uses: actions/setup-node@v4
27
+ with:
28
+ node-version-file: 'package.json'
29
+ check-latest: true
30
+ cache: 'npm'
31
+
32
+ - name: Check if version is published
33
+ id: check
34
+ run: |
35
+ currentVersion="$( node -e "console.log(require('./package.json').version)" )"
36
+ isPublished="$( npm view tileserver-gl versions --json | jq -c --arg cv "$currentVersion" 'any(. == $cv)' )"
37
+ echo "version=$currentVersion" >> "$GITHUB_OUTPUT"
38
+ echo "published=$isPublished" >> "$GITHUB_OUTPUT"
39
+ echo "currentVersion: $currentVersion"
40
+ echo "isPublished: $isPublished"
41
+ outputs:
42
+ published: ${{ steps.check.outputs.published }}
43
+ version: ${{ steps.check.outputs.version }}
44
+
17
45
  release:
46
+ needs: release-check
47
+ if: ${{ needs.release-check.outputs.published == 'false' }}
18
48
  name: 'Build, Test, Publish'
19
49
  runs-on: ubuntu-22.04
50
+ env:
51
+ PACKAGE_VERSION: ${{ needs.release-check.outputs.version }}
20
52
  steps:
21
53
  - name: Check out repository ✨
22
54
  uses: actions/checkout@v4
@@ -54,17 +86,23 @@ jobs:
54
86
  - name: Remove Test Data
55
87
  run: rm -R test_data*
56
88
 
57
- - name: Publish to Full Version NPM
89
+ - name: Get release type
90
+ id: prepare_release
91
+ run: |
92
+ RELEASE_TYPE="$(node -e "console.log(require('semver').prerelease('${{ needs.release-check.outputs.version }}') ? 'prerelease' : 'regular')")"
93
+ if [[ $RELEASE_TYPE == 'regular' ]]; then
94
+ echo "prerelease=false" >> "$GITHUB_OUTPUT"
95
+ else
96
+ echo "prerelease=true" >> "$GITHUB_OUTPUT"
97
+ fi
98
+
99
+ - name: Publish to NPM
58
100
  run: |
59
101
  npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
60
- npm publish --access public
102
+ npm publish --access public --tag ${{ needs.release-check.outputs.prerelease == 'true' && 'next' || 'latest' }}
61
103
  env:
62
104
  NPM_TOKEN: ${{ github.event.inputs.npm_token }}
63
105
 
64
- - name: Get version
65
- run: |
66
- echo "PACKAGE_VERSION=$(grep '"version"' package.json | cut -d '"' -f 4 | head -n 1)" >> $GITHUB_ENV
67
-
68
106
  - name: Set up QEMU
69
107
  uses: docker/setup-qemu-action@v3
70
108
  with:
@@ -84,24 +122,42 @@ jobs:
84
122
  with:
85
123
  context: .
86
124
  push: true
87
- tags: maptiler/tileserver-gl:latest, maptiler/tileserver-gl:v${{ env.PACKAGE_VERSION }}
125
+ tags: |
126
+ maptiler/tileserver-gl:${{ needs.release-check.outputs.prerelease == 'true' && 'next' || 'latest' }},
127
+ maptiler/tileserver-gl:v${{ env.PACKAGE_VERSION }}
88
128
  platforms: linux/arm64,linux/amd64
89
- # experimental: https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#cache-backend-api
90
129
  cache-from: type=gha
91
130
  cache-to: type=gha,mode=max
92
131
 
132
+ - name: Extract changelog for version
133
+ run: |
134
+ awk '/^##/ { p = 0 }; p == 1 { print }; $0 == "## ${{ env.PACKAGE_VERSION }}" { p = 1 };' CHANGELOG.md > changelog_for_version.md
135
+ cat changelog_for_version.md
136
+
137
+ - name: Publish to Github
138
+ uses: ncipollo/release-action@v1
139
+ env:
140
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
141
+ with:
142
+ tag: v${{ env.PACKAGE_VERSION }}
143
+ name: v${{ env.PACKAGE_VERSION }}
144
+ bodyFile: changelog_for_version.md
145
+ allowUpdates: true
146
+ draft: false
147
+ prerelease: ${{ env.PRERELEASE }}
148
+
93
149
  - name: Create Tileserver Light Directory
94
150
  run: node publish.js --no-publish
95
151
 
96
152
  - name: Install node dependencies
97
- run: npm install
153
+ run: npm ci --prefer-offline --no-audit
98
154
  working-directory: ./light
99
155
 
100
156
  - name: Publish to Light Version NPM
101
157
  working-directory: ./light
102
158
  run: |
103
159
  npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
104
- npm publish --access public
160
+ npm publish --access public --tag ${{ needs.release-check.outputs.prerelease == 'true' && 'next' || 'latest' }}
105
161
  env:
106
162
  NPM_TOKEN: ${{ github.event.inputs.npm_token }}
107
163
 
@@ -111,8 +167,9 @@ jobs:
111
167
  context: ./light
112
168
  file: ./light/Dockerfile
113
169
  push: true
114
- tags: maptiler/tileserver-gl-light:latest, maptiler/tileserver-gl-light:v${{ env.PACKAGE_VERSION }}
170
+ tags: |
171
+ maptiler/tileserver-gl-light:${{ needs.release-check.outputs.prerelease == 'true' && 'next' || 'latest' }},
172
+ maptiler/tileserver-gl-light:v${{ env.PACKAGE_VERSION }}
115
173
  platforms: linux/arm64,linux/amd64
116
- # experimental: https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#cache-backend-api
117
174
  cache-from: type=gha
118
175
  cache-to: type=gha,mode=max
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # tileserver-gl changelog
2
+
3
+ ## 5.1.0-pre.0
4
+ * Update recommended node to v22 + Update docker images to use node 22 (https://github.com/maptiler/tileserver-gl/pull/1438) by @acalcutt
5
+ * Upgrade Express to v5 + Canvas to v3 + code cleanup (https://github.com/maptiler/tileserver-gl/pull/1429) by @acalcutt
6
+ * Terrain Preview and simple Elevation Query (https://github.com/maptiler/tileserver-gl/pull/1425 and https://github.com/maptiler/tileserver-gl/pull/1432) by @okimiko
7
+ * add progressive rendering option for static jpeg images (#1397) by @samuel-git
8
+
9
+ ## 5.0.0
10
+ * Update Maplibre-Native to [v6.0.0](https://github.com/maplibre/maplibre-native/releases/tag/node-v6.0.0) release by @acalcutt in https://github.com/maptiler/tileserver-gl/pull/1376 and @dependabot in https://github.com/maptiler/tileserver-gl/pull/1381
11
+ * This first release that use Metal for rendering instead of OpenGL (ES) for macOS.
12
+ * This the first release that uses OpenGL (ES) 3.0 on Windows and Linux
13
+ * Note: Windows users may need to update their [c++ redistributable ](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170) for maplibre-native v6.0.0
package/Dockerfile CHANGED
@@ -16,7 +16,7 @@ RUN set -ex; \
16
16
  gnupg; \
17
17
  mkdir -p /etc/apt/keyrings; \
18
18
  curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg; \
19
- echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list; \
19
+ echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list; \
20
20
  apt-get -qq update; \
21
21
  apt-get install -y nodejs; \
22
22
  npm i -g npm@latest; \
package/PUBLISHING.md CHANGED
@@ -1,13 +1,19 @@
1
1
  # Publishing new version
2
2
 
3
- - Update version in `package.json`
4
- - `git tag vx.x.x`
5
- - `git push --tags`
6
- - `docker buildx build --platform linux/amd64 -t maptiler/tileserver-gl:latest -t maptiler/tileserver-gl:[version] .`
7
- - `docker push maptiler/tileserver-gl --all-tags`
8
- - `npm publish --access public` or `node publish.js`
9
- - `node publish.js --no-publish`
10
- - `cd light`
11
- - `docker buildx build --platform linux/amd64 -t maptiler/tileserver-gl-light:latest -t maptiler/tileserver-gl-light:[version] .`
12
- - `docker push maptiler/tileserver-gl-light --all-tags`
13
- - `npm publish --access public`
3
+ 1.) Change the version number in package.json. Run the following command in the package root directory, replacing <update_type> with one of the semantic versioning release types (prerelease, prepatch, preminor, premajor, patch, minor, major):
4
+ npm version <update_type> --preid pre --no-git-tag-version
5
+
6
+ --preid specifies which suffix to use in the release such as pre, next, beta, rc, etc.
7
+
8
+ prepatch, preminor, and premajor start a new series of pre-releases while bumping the patch, minor, or major version. E.g. premajor with --preid pre would do a prerelease for a new major using the -pre suffix (i.e. it would be a new major with -pre.0)
9
+
10
+ You can use prerelease to bump the version for a new pre-release version. E.g. you could run npm version prerelease --preid pre --no-git-tag-version to go from -pre.0 to -pre.1.
11
+
12
+ For regular versions, you can use patch, minor, or major. E.g. npm version major --no-git-tag-version.
13
+
14
+ 2.) Update the changelog, which can be found in CHANGELOG.md. The heading must match ## <VERSION> exactly, or it will not be picked up. For example, for version 5.0.0:
15
+ ```## 5.0.0```
16
+
17
+ 3.) Commit and push the changes.
18
+
19
+ 4.) Run the 'Build, Test, Release' github workflow. The workflow will create a NPM, Docker, and Github release and Tag.
@@ -0,0 +1,5 @@
1
+ * Update recommended node to v22 + Update docker images to use node 22 (https://github.com/maptiler/tileserver-gl/pull/1438) by @acalcutt
2
+ * Upgrade Express to v5 + Canvas to v3 + code cleanup (https://github.com/maptiler/tileserver-gl/pull/1429) by @acalcutt
3
+ * Terrain Preview and simple Elevation Query (https://github.com/maptiler/tileserver-gl/pull/1425 and https://github.com/maptiler/tileserver-gl/pull/1432) by @okimiko
4
+ * add progressive rendering option for static jpeg images (#1397) by @samuel-git
5
+
package/docs/config.rst CHANGED
@@ -94,7 +94,8 @@ Use ``false`` to disable the front page altogether (404).
94
94
  -----------------
95
95
 
96
96
  You can use this to specify options for the generation of images in the supported file formats.
97
- For JPEG and WebP, the only supported option is ``quality`` [0-100].
97
+ For WebP, the only supported option is ``quality`` [0-100].
98
+ For JPEG, the only supported options are ``quality`` [0-100] and ``progressive`` [true, false].
98
99
  For PNG, the full set of options `exposed by the sharp library <https://sharp.pixelplumbing.com/api-output#png>`_ is available, except ``force`` and ``colours`` (use ``colors``). If not set, their values are the defaults from ``sharp``.
99
100
 
100
101
  For example::
@@ -237,9 +238,26 @@ For example::
237
238
  }
238
239
  }
239
240
 
240
-
241
241
  The data source does not need to be specified here unless you explicitly want to serve the raw data.
242
242
 
243
+ Serving Terrain Tiles
244
+ --------------
245
+
246
+ If you serve terrain tiles, it is possible to configure an ``encoding`` with ``mapbox`` or ``terrarium`` to enable a terrain preview mode and the ``elevation`` api for the ``data`` endpoint.
247
+
248
+ For example::
249
+
250
+ "data": {
251
+ "terrain1": {
252
+ "mbtiles": "terrain1.mbtiles",
253
+ "encoding": "mapbox"
254
+ },
255
+ "terrain2": {
256
+ "pmtiles": "terrain2.pmtiles"
257
+ "encoding": "terrarium"
258
+ }
259
+ }
260
+
243
261
  Referencing local files from style JSON
244
262
  =======================================
245
263
 
@@ -282,7 +300,7 @@ For example::
282
300
  "source3": {
283
301
  "url": "pmtiles://https://foo.lan/source3.pmtiles",
284
302
  "type": "vector"
285
- },
303
+ }
286
304
  }
287
305
 
288
306
  Alternatively, you can use ``pmtiles://{source2}`` to reference existing data object from the config.
@@ -100,6 +100,14 @@ Source data
100
100
 
101
101
  * TileJSON at ``/data/{id}.json``
102
102
 
103
+ * If terrain mbtile data is served and ``encoding`` is configured (see config) the elevation can be queried
104
+
105
+ * by ``/data/{id}/elevation/{z}/{x}/{y}`` for the tile
106
+
107
+ * or ``/data/{id}/elevation/{z}/{long}/{lat}`` for the coordinate
108
+
109
+ * the result will be a json object like ``{"z":7,"x":68,"y":45,"red":134,"green":66,"blue":0,"latitude":11.84069,"longitude":46.04798,"elevation":1602}``
110
+
103
111
  Static files
104
112
  ===========
105
113
  * Static files are served at ``/files/{filename}``
@@ -22,7 +22,7 @@ npm is supported on the following platforms with `Native Dependencies <#id1>`_ i
22
22
  - Operating systems:
23
23
 
24
24
  - Ubuntu 22.04 (x64/arm64)
25
- - macOS 12 (x64/arm64)
25
+ - macOS 14 (x64/arm64)
26
26
  - Windows (x64)
27
27
 
28
28
  - Node.js 18,20
@@ -50,13 +50,13 @@ Ubuntu 22.04 (x64/arm64)
50
50
  ~~~~~~~~~~~~~~~~~~~~~~~~~~
51
51
  - apt install build-essential pkg-config xvfb libglfw3-dev libuv1-dev libjpeg-turbo8 libicu70 libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev gir1.2-rsvg-2.0 librsvg2-2 librsvg2-common libcurl4-openssl-dev libpixman-1-dev libpixman-1-0
52
52
 
53
- MacOS 12 (x64/arm64)
53
+ MacOS 14 (x64/arm64)
54
54
  ~~~~~~~~~~~~~~~~~~~~~~
55
- - brew install pkg-config cairo libpng jpeg giflib
55
+ - brew install pkg-config cairo pango libpng jpeg giflib librsvg
56
56
 
57
57
  Windows (x64)
58
58
  ~~~~~~~~~~~~~~~~~~~~~~~~~
59
- - `Microsoft Visual C++ 2015-2022 Redistributable <https://aka.ms/vs/17/release/vc_redist.x64.exe>`_
59
+ - `Microsoft Visual C++ Redistributable <https://aka.ms/vs/17/release/vc_redist.x64.exe>`_
60
60
 
61
61
  ``tileserver-gl-light`` on npm
62
62
  ==============================
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "tileserver-gl-light",
3
- "version": "4.13.3",
3
+ "version": "5.1.0-pre.0",
4
4
  "description": "Map tile server for JSON GL styles - serving vector tiles",
5
5
  "main": "src/main.js",
6
6
  "bin": "src/main.js",
7
7
  "type": "module",
8
8
  "scripts": {
9
9
  "test": "mocha test/**.js --timeout 10000 --exit",
10
+ "test-docker": "xvfb-run npm test",
10
11
  "lint:yml": "yamllint --schema=CORE_SCHEMA *.{yml,yaml}",
11
12
  "lint:js": "npm run lint:eslint && npm run lint:prettier",
12
13
  "lint:js:fix": "npm run lint:eslint:fix && npm run lint:prettier:fix",
@@ -25,20 +26,21 @@
25
26
  "@maplibre/maplibre-gl-style-spec": "20.3.1",
26
27
  "@sindresorhus/fnv1a": "3.1.0",
27
28
  "advanced-pool": "0.3.3",
28
- "axios": "^1.7.6",
29
+ "axios": "^1.7.7",
29
30
  "chokidar": "3.6.0",
30
31
  "clone": "2.1.2",
31
32
  "color": "4.2.3",
32
33
  "commander": "12.1.0",
33
34
  "cors": "2.8.5",
34
- "express": "4.19.2",
35
+ "express": "5.0.1",
35
36
  "handlebars": "4.7.8",
36
37
  "http-shutdown": "1.2.2",
37
38
  "morgan": "1.10.0",
38
39
  "pbf": "4.0.1",
39
40
  "pmtiles": "3.0.7",
40
- "proj4": "2.12.0",
41
+ "proj4": "2.12.1",
41
42
  "sanitize-filename": "1.6.3",
43
+ "semver": "^7.6.3",
42
44
  "tileserver-gl-styles": "2.0.0"
43
45
  },
44
46
  "keywords": [
@@ -0,0 +1,51 @@
1
+ class ElevationInfoControl {
2
+ constructor(options) {
3
+ this.url = options["url"];
4
+ }
5
+
6
+ getDefaultPosition() {
7
+ const defaultPosition = "bottom-left";
8
+ return defaultPosition;
9
+ }
10
+
11
+ onAdd(map) {
12
+ this.map = map;
13
+ this.controlContainer = document.createElement("div");
14
+ this.controlContainer.classList.add("maplibregl-ctrl");
15
+ this.controlContainer.classList.add("maplibregl-ctrl-group");
16
+ this.controlContainer.classList.add("maplibre-ctrl-elevation");
17
+ this.controlContainer.textContent = "Elevation: Click on Map";
18
+
19
+ map.on('click', (e) => {
20
+ var url = this.url;
21
+ var coord = {"z": Math.floor(map.getZoom()), "x": e.lngLat["lng"], "y": e.lngLat["lat"]};
22
+ for(var key in coord) {
23
+ url = url.replace(new RegExp('{'+ key +'}','g'), coord[key]);
24
+ }
25
+
26
+ let request = new XMLHttpRequest();
27
+ request.open("GET", url, true);
28
+ request.onload = () => {
29
+ if (request.status !== 200) {
30
+ this.controlContainer.textContent = "Elevation: No value";
31
+ } else {
32
+ this.controlContainer.textContent = `Elevation: ${JSON.parse(request.responseText).elevation} (${JSON.stringify(coord)})`;
33
+ }
34
+ }
35
+ request.send();
36
+ });
37
+ return this.controlContainer;
38
+ }
39
+
40
+ onRemove() {
41
+ if (
42
+ !this.controlContainer ||
43
+ !this.controlContainer.parentNode ||
44
+ !this.map
45
+ ) {
46
+ return;
47
+ }
48
+ this.controlContainer.parentNode.removeChild(this.controlContainer);
49
+ this.map = undefined;
50
+ }
51
+ };
@@ -114,7 +114,7 @@ section {
114
114
  }
115
115
  .details h3 {
116
116
  font-size: 18px;
117
- margin-top: 25px;
117
+ margin-top: 5px;
118
118
  }
119
119
  .details p {
120
120
  padding: 0;
@@ -4,20 +4,27 @@
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
6
6
  <title>{{name}} - TileServer GL</title>
7
- {{#is_vector}}
7
+ {{#use_maplibre}}
8
8
  <link rel="stylesheet" type="text/css" href="{{public_url}}maplibre-gl.css{{&key_query}}" />
9
9
  <link rel="stylesheet" type="text/css" href="{{public_url}}maplibre-gl-inspect.css{{&key_query}}" />
10
10
  <script src="{{public_url}}maplibre-gl.js{{&key_query}}"></script>
11
11
  <script src="{{public_url}}maplibre-gl-inspect.js{{&key_query}}"></script>
12
+ <script src="{{public_url}}elevation-control.js{{&key_query}}"></script>
12
13
  <style>
13
14
  body {background:#fff;color:#333;font-family:Arial, sans-serif;}
15
+ {{^is_terrain}}
14
16
  #map {position:absolute;top:0;left:0;right:250px;bottom:0;}
17
+ {{/is_terrain}}
18
+ {{#is_terrain}}
19
+ #map { position:absolute; top:0; bottom:0; left:0; right:0; }
20
+ {{/is_terrain}}
15
21
  h1 {position:absolute;top:5px;right:0;width:240px;margin:0;line-height:20px;font-size:20px;}
16
22
  #layerList {position:absolute;top:35px;right:0;bottom:0;width:240px;overflow:auto;}
17
23
  #layerList div div {width:15px;height:15px;display:inline-block;}
24
+ .maplibre-ctrl-elevation { padding-left: 5px; padding-right: 5px; }
18
25
  </style>
19
- {{/is_vector}}
20
- {{^is_vector}}
26
+ {{/use_maplibre}}
27
+ {{^use_maplibre}}
21
28
  <link rel="stylesheet" type="text/css" href="{{public_url}}leaflet.css{{&key_query}}" />
22
29
  <script src="{{public_url}}leaflet.js{{&key_query}}"></script>
23
30
  <script src="{{public_url}}leaflet-hash.js{{&key_query}}"></script>
@@ -37,23 +44,22 @@
37
44
  background-image: url({{public_url}}images/marker-icon.png{{&key_query}});
38
45
  }
39
46
  </style>
40
- {{/is_vector}}
47
+ {{/use_maplibre}}
41
48
  </head>
42
49
  <body>
43
- {{#is_vector}}
50
+ {{#use_maplibre}}
44
51
  <h1>{{name}}</h1>
45
52
  <div id="map"></div>
53
+ {{^is_terrain}}
46
54
  <div id="layerList"></div>
47
55
  <pre id="propertyList"></pre>
56
+ {{/is_terrain}}
48
57
  <script>
49
- var keyMatch = location.search.match(/[\?\&]key=([^&]+)/i);
50
- var keyParam = keyMatch ? '?key=' + keyMatch[1] : '';
51
-
52
- var map = new maplibregl.Map({
53
- container: 'map',
54
- hash: true,
55
- maxPitch: 85,
56
- style: {
58
+ var keyMatch = location.search.match(/[\?\&]key=([^&]+)/i);
59
+ var keyParam = keyMatch ? '?key=' + keyMatch[1] : '';
60
+
61
+ {{^is_terrain}}
62
+ var style = {
57
63
  version: 8,
58
64
  sources: {
59
65
  'vector_layer_': {
@@ -62,37 +68,110 @@
62
68
  }
63
69
  },
64
70
  layers: []
65
- }
66
- });
67
- map.addControl(new maplibregl.NavigationControl());
68
- var inspect = new MaplibreInspect({
69
- showInspectMap: true,
70
- showInspectButton: false
71
- });
72
- map.addControl(inspect);
73
- map.on('styledata', function() {
74
- var layerList = document.getElementById('layerList');
75
- layerList.innerHTML = '';
76
- Object.keys(inspect.sources).forEach(function(sourceId) {
77
- var layerIds = inspect.sources[sourceId];
78
- layerIds.forEach(function(layerId) {
79
- var item = document.createElement('div');
80
- item.innerHTML = '<div style="' +
81
- 'background:' + inspect.assignLayerColor(layerId) + ';' +
82
- '"></div> ' + layerId;
83
- layerList.appendChild(item);
84
- });
85
- })
86
- });
71
+ };
72
+ {{/is_terrain}}
73
+ {{#is_terrain}}
74
+
75
+ var style = {
76
+ version: 8,
77
+ sources: {
78
+ "terrain": {
79
+ "type": "raster-dem",
80
+ "url": "{{public_url}}data/{{id}}.json",
81
+ "encoding": "{{terrain_encoding}}"
82
+ },
83
+ "hillshade": {
84
+ "type": "raster-dem",
85
+ "url": "{{public_url}}data/{{id}}.json",
86
+ "encoding": "{{terrain_encoding}}"
87
+ }
88
+ },
89
+ "terrain": {
90
+ "source": "terrain"
91
+ },
92
+ "layers": [
93
+ {
94
+ "id": "background",
95
+ "paint": {
96
+ {{#if is_terrainrgb}}
97
+ "background-color": "hsl(190, 99%, 63%)"
98
+ {{else}}
99
+ "background-color": "hsl(0, 100%, 25%)"
100
+ {{/if}}
101
+ },
102
+ "type": "background"
103
+ },
104
+ {
105
+ "id": "hillshade",
106
+ "source": "hillshade",
107
+ "type": "hillshade",
108
+ "paint": {
109
+ "hillshade-shadow-color": "hsl(39, 21%, 33%)",
110
+ "hillshade-illumination-direction": 315,
111
+ "hillshade-exaggeration": 0.8
112
+ }
113
+ }
114
+ ]
115
+ };
116
+ {{/is_terrain}}
117
+
118
+ var map = new maplibregl.Map({
119
+ container: 'map',
120
+ hash: true,
121
+ maxPitch: 85,
122
+ style: style
123
+ });
124
+
125
+ map.addControl(new maplibregl.NavigationControl({
126
+ visualizePitch: true,
127
+ showZoom: true,
128
+ showCompass: true
129
+ }));
130
+ {{#is_terrain}}
131
+
132
+ map.addControl(
133
+ new maplibregl.TerrainControl({
134
+ source: "terrain",
135
+ })
136
+ );
137
+
138
+ map.addControl(
139
+ new ElevationInfoControl({
140
+ url: "{{public_url}}data/{{id}}/elevation/{z}/{x}/{y}"
141
+ })
142
+ );
143
+ {{/is_terrain}}
144
+ {{^is_terrain}}
145
+
146
+ var inspect = new MaplibreInspect({
147
+ showInspectMap: true,
148
+ showInspectButton: false
149
+ });
150
+ map.addControl(inspect);
151
+
152
+ map.on('styledata', function() {
153
+ var layerList = document.getElementById('layerList');
154
+ layerList.innerHTML = '';
155
+ Object.keys(inspect.sources).forEach(function(sourceId) {
156
+ var layerIds = inspect.sources[sourceId];
157
+ layerIds.forEach(function(layerId) {
158
+ var item = document.createElement('div');
159
+ item.innerHTML = '<div style="' +
160
+ 'background:' + inspect.assignLayerColor(layerId) + ';' +
161
+ '"></div> ' + layerId;
162
+ layerList.appendChild(item);
163
+ });
164
+ })
165
+ });
166
+ {{/is_terrain}}
87
167
  </script>
88
- {{/is_vector}}
89
- {{^is_vector}}
168
+ {{/use_maplibre}}
169
+ {{^use_maplibre}}
90
170
  <h1 style="display:none;">{{name}}</h1>
91
171
  <div id='map'></div>
92
172
  <script>
93
- var keyMatch = location.search.match(/[\?\&]key=([^&]+)/i);
94
- var keyParam = keyMatch ? '?key=' + keyMatch[1] : '';
95
-
173
+ var keyMatch = location.search.match(/[\?\&]key=([^&]+)/i);
174
+ var keyParam = keyMatch ? '?key=' + keyMatch[1] : '';
96
175
  var map = L.map('map', { zoomControl: false });
97
176
  new L.Control.Zoom({ position: 'topright' }).addTo(map);
98
177
 
@@ -129,7 +208,7 @@
129
208
  attribution: tile_attribution
130
209
  }).addTo(map);
131
210
  }
132
-
211
+
133
212
  map.eachLayer(function(layer) {
134
213
  // do not add scale prefix even if retina display is detected
135
214
  layer.scalePrefix = '.';
@@ -141,6 +220,6 @@
141
220
  new L.Hash(map);
142
221
  }, 0);
143
222
  </script>
144
- {{/is_vector}}
223
+ {{/use_maplibre}}
145
224
  </body>
146
225
  </html>
@@ -6,10 +6,15 @@
6
6
  <title>TileServer GL - Server for vector and raster maps with GL styles</title>
7
7
  <link rel="stylesheet" type="text/css" href="{{public_url}}index.css{{&key_query}}" />
8
8
  <script>
9
- function toggle_xyz(id) {
9
+ function toggle_link(id, link) {
10
10
  var el = document.getElementById(id);
11
11
  var s = el.style;
12
- s.display = s.display == 'none' ? 'inline-block' : 'none';
12
+ if (s.display == 'none') {
13
+ s.display = 'inline-block';
14
+ } else if (el.value == link) {
15
+ s.display = 'none';
16
+ }
17
+ el.value = link;
13
18
  el.setSelectionRange(0, el.value.length);
14
19
  return false;
15
20
  }
@@ -37,7 +42,7 @@
37
42
  <div class="filter-details">
38
43
  <h3>Filter styles and data by name or identifier</h3>
39
44
  <!-- filter input , needs to call filter() when content changes...-->
40
- <input id="filter" type="text" oninput="filter()" placeholder="Start typing name or identifier" />
45
+ <input id="filter" type="text" oninput="filter()" placeholder="Start typing name or identifier" autofocus />
41
46
  </div>
42
47
  </div>
43
48
  </div>
@@ -66,8 +71,8 @@
66
71
  | <a href="{{public_url}}styles/{{@key}}/wmts.xml{{&../key_query}}">WMTS</a>
67
72
  {{/if}}
68
73
  {{#if xyz_link}}
69
- | <a href="#" onclick="return toggle_xyz('xyz_style_{{@key}}');">XYZ</a>
70
- <input id="xyz_style_{{@key}}" type="text" value="{{&xyz_link}}" style="display:none;" />
74
+ | <a href="#" onclick="return toggle_link('xyz_style_{{@key}}', '{{&xyz_link}}');">XYZ</a>
75
+ <input id="xyz_style_{{@key}}" type="text" value="" style="display:none;" />
71
76
  {{/if}}
72
77
  </p>
73
78
  </div>
@@ -105,9 +110,12 @@
105
110
  <p class="services">
106
111
  services: <a href="{{public_url}}data/{{@key}}.json{{&../key_query}}">TileJSON</a>
107
112
  {{#if xyz_link}}
108
- | <a href="#" onclick="return toggle_xyz('xyz_data_{{@key}}');">XYZ</a>
109
- <input id="xyz_data_{{@key}}" type="text" value="{{&xyz_link}}" style="display:none;" />
113
+ | <a href="#" onclick="return toggle_link('link_data_{{@key}}', '{{&xyz_link}}');">XYZ</a>
114
+ {{/if}}
115
+ {{#if elevation_link}}
116
+ | <a href="#" onclick="return toggle_link('link_data_{{@key}}', '{{&elevation_link}}');">Elevation</a>
110
117
  {{/if}}
118
+ <input id="link_data_{{@key}}" type="text" value="" style="display:none;" />
111
119
  </p>
112
120
  </div>
113
121
  <div class="viewers">
@@ -116,6 +124,9 @@
116
124
  {{/is_vector}}
117
125
  {{^is_vector}}
118
126
  <a class="btn" href="{{public_url}}data/{{@key}}/{{&../key_query}}{{viewer_hash}}">View</a>
127
+ {{#elevation_link}}
128
+ <a class="btn" href="{{public_url}}data/preview/{{@key}}/{{&../key_query}}{{viewer_hash}}">Preview Terrain</a>
129
+ {{/elevation_link}}
119
130
  {{/is_vector}}
120
131
  </div>
121
132
  </div>