tileserver-gl 5.5.0-pre.7 → 5.6.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.
package/CHANGELOG.md CHANGED
@@ -1,63 +1,77 @@
1
1
  # tileserver-gl changelog
2
2
 
3
- ## 5.5.0-pre.6
4
- * Add S3 support for PMTiles with multiple AWS credential profiles (https://github.com/maptiler/tileserver-gl/pull/1779) by @acalcutt
5
- * Create .aws directory passthrough folder in Dockerfile (https://github.com/maptiler/tileserver-gl/pull/1784) by @acalcutt
6
- * Update eslint to v9 (https://github.com/maptiler/tileserver-gl/pull/1473) by @acalcutt
7
- * Fix Renderer Crashes from Failed Fetches (https://github.com/maptiler/tileserver-gl/pull/1798) by @acalcutt
8
- * Add Visual Regression Tests for Static Image Overlays (https://github.com/maptiler/tileserver-gl/pull/1792) by @acalcutt
9
- * Fix S3 URL parsing for nested paths in AWS buckets (https://github.com/maptiler/tileserver-gl/pull/1819) by @acalcutt
10
- * Fix Renderer Crashes and Memory Leak (https://github.com/maptiler/tileserver-gl/pull/1825) by @acalcutt
11
- * Fix loading local data sources (PMTiles/MBTiles) specified in style (https://github.com/maptiler/tileserver-gl/pull/1855) by @acalcutt
12
- * **BREAKING**: Change 'sparse' option default based on tile format - vector tiles (pbf) default to false (204), raster tiles default to true (404 for overzoom) (https://github.com/maptiler/tileserver-gl/pull/1855) by @acalcutt
13
- * Revert "fix(deps): bump maplibre-gl from 5.13.0 to 5.14.0 (https://github.com/maptiler/tileserver-gl/pull/1853)
3
+ ## master
4
+ ### ✨ Features and improvements
5
+ - _...Add new stuff here..._
6
+
7
+ ### 🐞 Bug fixes
8
+ - _...Add new stuff here..._
9
+
10
+ ## 5.6.0-pre.0
11
+ ### ✨ Features and improvements
12
+ - feat: Add ignore-missing-files cli option to avoid crashing at startup ([#1896](https://github.com/maptiler/tileserver-gl/pull/1896)) (by [andrewlaguna824](https://github.com/andrewlaguna824))
13
+
14
+ ## 5.5.0
15
+ - Add S3 support for PMTiles with multiple AWS credential profiles (https://github.com/maptiler/tileserver-gl/pull/1779) by @acalcutt
16
+ - Create .aws directory passthrough folder in Dockerfile (https://github.com/maptiler/tileserver-gl/pull/1784) by @acalcutt
17
+ - Update eslint to v9 (https://github.com/maptiler/tileserver-gl/pull/1473) by @acalcutt
18
+ - Fix Renderer Crashes from Failed Fetches (https://github.com/maptiler/tileserver-gl/pull/1798) by @acalcutt
19
+ - Add Visual Regression Tests for Static Image Overlays (https://github.com/maptiler/tileserver-gl/pull/1792) by @acalcutt
20
+ - Fix S3 URL parsing for nested paths in AWS buckets (https://github.com/maptiler/tileserver-gl/pull/1819) by @acalcutt
21
+ - Fix Renderer Crashes and Memory Leak (https://github.com/maptiler/tileserver-gl/pull/1825) by @acalcutt
22
+ - Fix loading local data sources (PMTiles/MBTiles) specified in style (https://github.com/maptiler/tileserver-gl/pull/1855) by @acalcutt
23
+ - Migrate NPM publishing to trusted publishing (OIDC) ([#1872](https://github.com/maptiler/tileserver-gl/pull/1872)) (by [app/copilot-swe-agent](https://github.com/app/copilot-swe-agent)
24
+ - Fix get elevation may return data from wrong point (https://github.com/maptiler/tileserver-gl/pull/1860) by @russellporter @acalcutt
25
+ - Hide xkbcomp warnings ([#1920](https://github.com/maptiler/tileserver-gl/pull/1920)) (by [acalcutt](https://github.com/acalcutt))
26
+ - **BREAKING**: Change 'sparse' option default based on tile format - vector tiles (pbf) default to false (204), raster tiles default to true (404 for overzoom) (https://github.com/maptiler/tileserver-gl/pull/1855) by @acalcutt
27
+ - **BREAKING**: Update Maplibre-Native to v6.3.0. Note that the linux version now requires Ubuntu 24.04 to match the maplibre-native binary. (https://github.com/maptiler/tileserver-gl/pull/1907) by @acalcutt @dependabot
14
28
 
15
29
  ## 5.4.0
16
- * Fix the issue where the tile URL cannot be correctly parsed with the HTTPS protocol when using an nginx proxy service (https://github.com/maptiler/tileserver-gl/pull/1578) by @dakanggo
17
- * Use jemalloc as memory allocator in the docker image (https://github.com/maptiler/tileserver-gl/pull/1574) by @MichielMortier
18
- * Rasters: Add tileSize to TileJSON (https://github.com/maptiler/tileserver-gl/pull/1559) by @roblabs
19
- * Allow a 'sparse' option per data source (https://github.com/maptiler/tileserver-gl/pull/1558) by @acalcutt
20
- * Updates Maplibre-gl-js to v5.6.2 and adds color-relief support (note: this is not yet supported by maplibre-native) (https://github.com/maptiler/tileserver-gl/pull/1591)
21
- * Fix getPublicUrl to handle relative and absolute URLs (https://github.com/maptiler/tileserver-gl/pull/1472) by @Monnte
22
- * Workaround for 'hillshade-method' not yet being suported in maplibre-native (https://github.com/maptiler/tileserver-gl/pull/1620) by @acalcutt
23
- * Updates Maplibre-native to v6.2.0. This should fix the macos metal support in Issue: (https://github.com/maptiler/tileserver-gl/issues/1402)
30
+ - Fix the issue where the tile URL cannot be correctly parsed with the HTTPS protocol when using an nginx proxy service (https://github.com/maptiler/tileserver-gl/pull/1578) by @dakanggo
31
+ - Use jemalloc as memory allocator in the docker image (https://github.com/maptiler/tileserver-gl/pull/1574) by @MichielMortier
32
+ - Rasters: Add tileSize to TileJSON (https://github.com/maptiler/tileserver-gl/pull/1559) by @roblabs
33
+ - Allow a 'sparse' option per data source (https://github.com/maptiler/tileserver-gl/pull/1558) by @acalcutt
34
+ - Updates Maplibre-gl-js to v5.6.2 and adds color-relief support (note: this is not yet supported by maplibre-native) (https://github.com/maptiler/tileserver-gl/pull/1591)
35
+ - Fix getPublicUrl to handle relative and absolute URLs (https://github.com/maptiler/tileserver-gl/pull/1472) by @Monnte
36
+ - Workaround for 'hillshade-method' not yet being suported in maplibre-native (https://github.com/maptiler/tileserver-gl/pull/1620) by @acalcutt
37
+ - Updates Maplibre-native to v6.2.0. This should fix the macos metal support in Issue: (https://github.com/maptiler/tileserver-gl/issues/1402)
24
38
 
25
39
  ## 5.3.0
26
- * Fix - Include public\resources js files on npm publish by specifying included files in package.json (https://github.com/maptiler/tileserver-gl/pull/1490) by @acalcutt
27
- * Fix - Various Updates and Fix RTL Plugin Load (https://github.com/maptiler/tileserver-gl/pull/1489) by @okimiko
28
- * Updates Maplibre-gl-js to v5 and adds globe support.
40
+ - Fix - Include public\resources js files on npm publish by specifying included files in package.json (https://github.com/maptiler/tileserver-gl/pull/1490) by @acalcutt
41
+ - Fix - Various Updates and Fix RTL Plugin Load (https://github.com/maptiler/tileserver-gl/pull/1489) by @okimiko
42
+ - Updates Maplibre-gl-js to v5 and adds globe support.
29
43
 
30
44
  ## 5.2.1
31
- * Fix invalid Delete of 'prepare' Script required for Light Build (https://github.com/maptiler/tileserver-gl/pull/1489) by @okimiko
45
+ - Fix invalid Delete of 'prepare' Script required for Light Build (https://github.com/maptiler/tileserver-gl/pull/1489) by @okimiko
32
46
 
33
47
 
34
48
  ## 5.2.0
35
- * Use npm packages for public/resources (https://github.com/maptiler/tileserver-gl/pull/1427) by @okimiko
36
- * use ttf files of googlefonts/opensans (https://github.com/maptiler/tileserver-gl/pull/1447) by @okimiko
37
- * Limit Elevation Lat/Long Output Length (https://github.com/maptiler/tileserver-gl/pull/1457) by @okimiko
38
- * Fetch style from url (https://github.com/maptiler/tileserver-gl/pull/1462) by @YoelRidgway
39
- * fix: memory leak on SIGHUP (https://github.com/maptiler/tileserver-gl/pull/1455) by @okimiko
40
- * fix: resolves Unimplemented type: 3 error for geojson format (https://github.com/maptiler/tileserver-gl/pull/1465) by @rjdjohnston
41
- * fix: Test light version in ct workflow - fix sqlite build in light (https://github.com/maptiler/tileserver-gl/pull/1477) by @acalcutt
42
- * fix: light version docker entrypoint permissions (https://github.com/maptiler/tileserver-gl/pull/1478) by @acalcutt
49
+ - Use npm packages for public/resources (https://github.com/maptiler/tileserver-gl/pull/1427) by @okimiko
50
+ - use ttf files of googlefonts/opensans (https://github.com/maptiler/tileserver-gl/pull/1447) by @okimiko
51
+ - Limit Elevation Lat/Long Output Length (https://github.com/maptiler/tileserver-gl/pull/1457) by @okimiko
52
+ - Fetch style from url (https://github.com/maptiler/tileserver-gl/pull/1462) by @YoelRidgway
53
+ - fix: memory leak on SIGHUP (https://github.com/maptiler/tileserver-gl/pull/1455) by @okimiko
54
+ - fix: resolves Unimplemented type: 3 error for geojson format (https://github.com/maptiler/tileserver-gl/pull/1465) by @rjdjohnston
55
+ - fix: Test light version in ct workflow - fix sqlite build in light (https://github.com/maptiler/tileserver-gl/pull/1477) by @acalcutt
56
+ - fix: light version docker entrypoint permissions (https://github.com/maptiler/tileserver-gl/pull/1478) by @acalcutt
43
57
 
44
58
  ## 5.1.3
45
- * Fix SIGHUP (broken since 5.1.x) (https://github.com/maptiler/tileserver-gl/pull/1452) by @okimiko
59
+ - Fix SIGHUP (broken since 5.1.x) (https://github.com/maptiler/tileserver-gl/pull/1452) by @okimiko
46
60
 
47
61
  ## 5.1.2
48
- * Fix broken light (invalid use of heavy dependencies) (https://github.com/maptiler/tileserver-gl/pull/1449) by @okimiko
62
+ - Fix broken light (invalid use of heavy dependencies) (https://github.com/maptiler/tileserver-gl/pull/1449) by @okimiko
49
63
 
50
64
  ## 5.1.1
51
- * Fix wrong node version in Docker image (https://github.com/maptiler/tileserver-gl/pull/1442) by @acalcutt
65
+ - Fix wrong node version in Docker image (https://github.com/maptiler/tileserver-gl/pull/1442) by @acalcutt
52
66
 
53
67
  ## 5.1.0
54
- * Update recommended node to v22 + Update docker images to use node 22 (https://github.com/maptiler/tileserver-gl/pull/1438) by @acalcutt
55
- * Upgrade Express to v5 + Canvas to v3 + code cleanup (https://github.com/maptiler/tileserver-gl/pull/1429) by @acalcutt
56
- * 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
57
- * add progressive rendering option for static jpeg images (#1397) by @samuel-git
68
+ - Update recommended node to v22 + Update docker images to use node 22 (https://github.com/maptiler/tileserver-gl/pull/1438) by @acalcutt
69
+ - Upgrade Express to v5 + Canvas to v3 + code cleanup (https://github.com/maptiler/tileserver-gl/pull/1429) by @acalcutt
70
+ - 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
71
+ - add progressive rendering option for static jpeg images (#1397) by @samuel-git
58
72
 
59
73
  ## 5.0.0
60
- * 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
61
- * This first release that use Metal for rendering instead of OpenGL (ES) for macOS.
62
- * This the first release that uses OpenGL (ES) 3.0 on Windows and Linux
63
- * 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
74
+ - 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
75
+ - This first release that use Metal for rendering instead of OpenGL (ES) for macOS.
76
+ - This the first release that uses OpenGL (ES) 3.0 on Windows and Linux
77
+ - 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/README.md CHANGED
@@ -9,7 +9,7 @@ Vector and raster maps with GL styles. Server-side rendering by MapLibre GL Nati
9
9
  Download vector tiles from [OpenMapTiles](https://data.maptiler.com/downloads/planet/).
10
10
  ## Getting Started with Node
11
11
 
12
- Make sure you have Node.js version **18.17.0** or above installed. Node 22 is recommended. (running `node -v` it should output something like `v22.x.x`). Running without docker requires [Native dependencies](https://maptiler-tileserver.readthedocs.io/en/latest/installation.html#npm) to be installed first.
12
+ Make sure you have Node.js version **20** or above installed. Node 24 is recommended. (running `node -v` it should output something like `v24.x.x`). Running without docker requires [Native dependencies](https://maptiler-tileserver.readthedocs.io/en/latest/installation.html#npm) to be installed first.
13
13
 
14
14
  Install `tileserver-gl` with server-side raster rendering of vector tiles with npm.
15
15
 
@@ -100,13 +100,23 @@ 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
103
+ * If terrain mbtile data is served and ``encoding`` is configured (see config) the elevation can be queried
104
104
 
105
105
  * by ``/data/{id}/elevation/{z}/{x}/{y}`` for the tile
106
106
 
107
107
  * or ``/data/{id}/elevation/{z}/{long}/{lat}`` for the coordinate
108
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}``
109
+ * the result will be a json object like ``{"z":7,"x":68,"y":45,"long":46.04798,"lat":11.84069,"elevation":1602,"pixelX":128,"pixelY":256}``
110
+
111
+ * for batch requests, POST to ``/data/{id}/elevation`` with a JSON body:
112
+
113
+ * Request: ``{"points": [{"lon": 45.5, "lat": 45.5, "z": 1}, ...]}``
114
+ * Response: ``[500, 200, null, ...]`` - array of elevations (or null if no data) in the same order as input
115
+
116
+ * for batch requests, POST to ``/data/{id}/elevation`` with a JSON body:
117
+
118
+ * Request: ``{"points": [{"lon": 45.5, "lat": 45.5, "z": 1}, ...]}``
119
+ * Response: ``[500, 200, null, ...]`` - array of elevations (or null if no data) in the same order as input
110
120
 
111
121
  * The elevation api is not available in the ``tileserver-gl-light`` version.
112
122
 
@@ -21,11 +21,11 @@ npm is supported on the following platforms with `Native Dependencies <#id1>`_ i
21
21
 
22
22
  - Operating systems:
23
23
 
24
- - Ubuntu 22.04 (x64/arm64)
25
- - macOS 14 (x64/arm64)
24
+ - Ubuntu 24.04 (x64/arm64)
25
+ - macOS 15 (x64/arm64)
26
26
  - Windows (x64)
27
27
 
28
- - Node.js 18(>=18.17.0),20,22
28
+ - Node.js 20,22,24
29
29
 
30
30
  Install globally from npmjs.
31
31
  ------------------------------
@@ -46,11 +46,11 @@ Install locally from source
46
46
  Native dependencies
47
47
  -------------------
48
48
 
49
- Ubuntu 22.04 (x64/arm64)
49
+ Ubuntu 24.04 (x64/arm64)
50
50
  ~~~~~~~~~~~~~~~~~~~~~~~~~~
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
51
+ - apt install build-essential python3-setuptools pkg-config xvfb libglfw3-dev libuv1-dev libjpeg-turbo8 libicu-dev libcairo2-dev libpango1.0-dev libpng-dev libjpeg-dev libgif-dev librsvg2-dev librsvg2-dev libcurl4-openssl-dev libpixman-1-dev
52
52
 
53
- MacOS 14 (x64/arm64)
53
+ MacOS 15 (x64/arm64)
54
54
  ~~~~~~~~~~~~~~~~~~~~~~
55
55
  - brew install pkg-config cairo pango libpng jpeg giflib librsvg harfbuzz
56
56
 
package/docs/usage.rst CHANGED
@@ -20,6 +20,7 @@ Getting started
20
20
  -C|--no-cors Disable Cross-origin resource sharing headers
21
21
  -u|--public_url <url> Enable exposing the server on subpaths, not necessarily the root of the domain
22
22
  --fetch-timeout <ms> Timeout in milliseconds for fetching remote tiles (default: 15000)
23
+ --ignore-missing-files Do not exit when referenced data files or remote sources are missing at startup; log a warning and continue running (useful when styles reference optional or not-yet-available sources)
23
24
  -V, --verbose [level] More verbose output (level 1-3)
24
25
  -V, --verbose, -V 1, or --verbose 1: Important operations
25
26
  -V 2 or --verbose 2: Detailed operations
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "tileserver-gl",
3
- "version": "5.5.0-pre.7",
3
+ "version": "5.6.0-pre.0",
4
4
  "description": "Map tile server for JSON GL styles - vector and server side generated raster tiles",
5
5
  "main": "src/main.js",
6
- "bin": "src/main.js",
6
+ "bin": {
7
+ "tileserver-gl": "src/main.js"
8
+ },
7
9
  "type": "module",
8
10
  "files": [
9
11
  "docs",
@@ -35,16 +37,16 @@
35
37
  "docker": "docker build . && docker run --rm -i -p 8080:8080 $(docker build -q .)"
36
38
  },
37
39
  "dependencies": {
38
- "@aws-sdk/client-s3": "^3.946.0",
40
+ "@aws-sdk/client-s3": "^3.966.0",
39
41
  "@jsse/pbfont": "^0.3.0",
40
42
  "@mapbox/mapbox-gl-rtl-text": "0.3.0",
41
43
  "@mapbox/mbtiles": "0.12.1",
42
44
  "@mapbox/polyline": "^1.2.1",
43
45
  "@mapbox/sphericalmercator": "2.0.2",
44
46
  "@mapbox/vector-tile": "2.0.4",
45
- "@maplibre/maplibre-gl-inspect": "1.8.1",
46
- "@maplibre/maplibre-gl-native": "6.2.0",
47
- "@maplibre/maplibre-gl-style-spec": "24.3.1",
47
+ "@maplibre/maplibre-gl-inspect": "1.8.2",
48
+ "@maplibre/maplibre-gl-native": "6.3.0",
49
+ "@maplibre/maplibre-gl-style-spec": "24.4.1",
48
50
  "@sindresorhus/fnv1a": "3.1.0",
49
51
  "advanced-pool": "0.3.3",
50
52
  "canvas": "3.2.0",
@@ -59,10 +61,10 @@
59
61
  "http-shutdown": "1.2.2",
60
62
  "leaflet": "1.9.4",
61
63
  "leaflet-hash": "0.2.1",
62
- "maplibre-gl": "5.13.0",
64
+ "maplibre-gl": "5.15.0",
63
65
  "morgan": "1.10.1",
64
66
  "pbf": "4.0.1",
65
- "pmtiles": "4.3.0",
67
+ "pmtiles": "4.3.2",
66
68
  "proj4": "2.20.2",
67
69
  "sanitize-filename": "1.6.3",
68
70
  "semver": "^7.7.3",
@@ -70,15 +72,15 @@
70
72
  "tileserver-gl-styles": "2.0.0"
71
73
  },
72
74
  "devDependencies": {
73
- "@commitlint/cli": "^20.2.0",
74
- "@commitlint/config-conventional": "^20.2.0",
75
- "@typescript-eslint/eslint-plugin": "^8.48.1",
76
- "@typescript-eslint/parser": "^8.48.1",
77
- "chai": "6.2.1",
75
+ "@commitlint/cli": "^20.3.1",
76
+ "@commitlint/config-conventional": "^20.3.0",
77
+ "@typescript-eslint/eslint-plugin": "^8.52.0",
78
+ "@typescript-eslint/parser": "^8.52.0",
79
+ "chai": "6.2.2",
78
80
  "cross-env": "^10.1.0",
79
- "eslint": "^9.39.1",
81
+ "eslint": "^9.39.2",
80
82
  "eslint-config-prettier": "^10.1.8",
81
- "eslint-plugin-jsdoc": "^61.4.1",
83
+ "eslint-plugin-jsdoc": "^61.5.0",
82
84
  "eslint-plugin-prettier": "^5.5.4",
83
85
  "eslint-plugin-security": "^3.0.1",
84
86
  "lint-staged": "^16.2.7",
@@ -87,7 +89,7 @@
87
89
  "pixelmatch": "^7.1.0",
88
90
  "prettier": "^3.7.4",
89
91
  "should": "^13.2.3",
90
- "supertest": "^7.1.4",
92
+ "supertest": "^7.2.2",
91
93
  "yaml-lint": "^1.7.0"
92
94
  },
93
95
  "keywords": [
@@ -98,7 +100,7 @@
98
100
  ],
99
101
  "license": "BSD-2-Clause",
100
102
  "engines": {
101
- "node": ">=18.17.0 <23"
103
+ "node": "20 || 22 || 24"
102
104
  },
103
105
  "repository": {
104
106
  "url": "git+https://github.com/maptiler/tileserver-gl.git",
@@ -1,6 +1,38 @@
1
1
  class ElevationInfoControl {
2
2
  constructor(options) {
3
3
  this.url = options["url"];
4
+ this.originalTerrain = null;
5
+ this.suppressDEMErrors = true;
6
+ this.setupErrorHandler();
7
+ }
8
+
9
+ setupErrorHandler() {
10
+ // Suppress DEM out-of-range errors that occur when placing markers at coordinates outside DEM coverage
11
+ const originalHandler = window.onerror;
12
+ window.onerror = (msg, url, line, col, error) => {
13
+ if (error && error.message && error.message.includes('out of range source coordinates for DEM data')) {
14
+ console.warn("DEM coordinate out of range (suppressed):", error);
15
+ return true; // Suppress the error
16
+ }
17
+ // Call original handler if it exists
18
+ if (typeof originalHandler === 'function') {
19
+ return originalHandler(msg, url, line, col, error);
20
+ }
21
+ };
22
+
23
+ // Also suppress promise rejections for DEM errors
24
+ const originalHandler2 = window.onunhandledrejection;
25
+ window.onunhandledrejection = (event) => {
26
+ if (event.reason && event.reason.message && event.reason.message.includes('out of range source coordinates for DEM data')) {
27
+ console.warn("DEM coordinate out of range (suppressed):", event.reason);
28
+ event.preventDefault();
29
+ return true;
30
+ }
31
+ // Call original handler if it exists
32
+ if (typeof originalHandler2 === 'function') {
33
+ return originalHandler2(event);
34
+ }
35
+ };
4
36
  }
5
37
 
6
38
  getDefaultPosition() {
@@ -10,6 +42,7 @@ class ElevationInfoControl {
10
42
 
11
43
  onAdd(map) {
12
44
  this.map = map;
45
+ this.originalTerrain = map.getTerrain();
13
46
  this.controlContainer = document.createElement("div");
14
47
  this.controlContainer.classList.add("maplibregl-ctrl");
15
48
  this.controlContainer.classList.add("maplibregl-ctrl-group");
@@ -19,29 +52,49 @@ class ElevationInfoControl {
19
52
  this.marker = new maplibregl.Marker();
20
53
 
21
54
  map.on('click', (e) => {
55
+ if (!map.transform.isPointOnMapSurface(e.point)) {
56
+ this.controlContainer.textContent = "Elevation: Click on Globe";
57
+ return;
58
+ }
59
+
22
60
  var url = this.url;
23
- var coord = {"z": Math.floor(map.getZoom()), "x": e.lngLat["lng"].toFixed(7), "y": e.lngLat["lat"].toFixed(7)};
24
- if (map.transform.isPointOnMapSurface(e.point)) {
25
- for(var key in coord) {
26
- url = url.replace(new RegExp('{'+ key +'}','g'), coord[key]);
27
- }
61
+ var lngLat = e.lngLat;
62
+
63
+ // Validate coordinates are within valid range
64
+ if (typeof lngLat !== 'object' || typeof lngLat.lng !== 'number' || typeof lngLat.lat !== 'number') {
65
+ this.controlContainer.textContent = "Elevation: Invalid coordinates";
66
+ return;
67
+ }
28
68
 
29
- this.marker.remove();
30
- this.marker.setLngLat(e.lngLat).addTo(this.map);
31
-
32
- let request = new XMLHttpRequest();
33
- request.open("GET", url, true);
34
- request.onload = () => {
35
- if (request.status !== 200) {
36
- this.controlContainer.textContent = "Elevation: No value";
37
- } else {
38
- this.controlContainer.textContent = `Elevation: ${JSON.parse(request.responseText).elevation} (${JSON.stringify(coord)})`;
39
- }
40
- };
41
- request.send();
42
- } else {
43
- this.controlContainer.textContent = "Elevation: Click on Globe";
69
+ var coord = {"z": Math.floor(map.getZoom()), "x": lngLat.lng.toFixed(7), "y": lngLat.lat.toFixed(7)};
70
+
71
+ for(var key in coord) {
72
+ url = url.replace(new RegExp('{'+ key +'}','g'), coord[key]);
73
+ }
74
+
75
+ try {
76
+ if (this.marker) {
77
+ this.marker.remove();
78
+ }
79
+
80
+ this.marker = new maplibregl.Marker();
81
+ this.marker.setLngLat({lng: lngLat.lng, lat: lngLat.lat});
82
+ this.marker.addTo(this.map);
83
+ } catch (_err) {
84
+ // If placement fails, continue without marker
85
+ console.error("Marker placement error:", _err);
44
86
  }
87
+
88
+ let request = new XMLHttpRequest();
89
+ request.open("GET", url, true);
90
+ request.onload = () => {
91
+ if (request.status !== 200) {
92
+ this.controlContainer.textContent = "Elevation: No value";
93
+ } else {
94
+ this.controlContainer.textContent = `Elevation: ${JSON.parse(request.responseText).elevation} (${JSON.stringify(coord)})`;
95
+ }
96
+ };
97
+ request.send();
45
98
  });
46
99
  return this.controlContainer;
47
100
  }
@@ -55,8 +108,17 @@ class ElevationInfoControl {
55
108
  return;
56
109
  }
57
110
  this.controlContainer.parentNode.removeChild(this.controlContainer);
111
+
112
+ // Restore terrain if it was originally enabled
113
+ if (this.originalTerrain && !this.map.getTerrain()) {
114
+ this.map.setTerrain(this.originalTerrain);
115
+ }
116
+
117
+ if (this.marker) {
118
+ this.marker.remove();
119
+ this.marker = undefined;
120
+ }
121
+
58
122
  this.map = undefined;
59
- this.marker.remove();
60
- this.marker = undefined;
61
123
  }
62
124
  };