From 7289e26563bac057d40bf3a9d22661d22fbcee77 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 7 Sep 2025 14:24:50 +0000 Subject: [PATCH] chore(deps): Bump maplibre-gl from 5.5.0 to 5.6.2 (#1308) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [maplibre-gl](https://github.com/maplibre/maplibre-gl-js) from 5.5.0 to 5.6.2.
Release notes

Sourced from maplibre-gl's releases.

v5.6.2

https://github.com/maplibre/maplibre-gl-js Changes since MapLibre GL JS v5.6.1:

🐞 Bug fixes

v5.6.1

https://github.com/maplibre/maplibre-gl-js Changes since MapLibre GL JS v5.6.0:

🐞 Bug fixes

v5.6.0

https://github.com/maplibre/maplibre-gl-js Changes since MapLibre GL JS v5.5.0:

✨ Features and improvements

🐞 Bug fixes

Changelog

Sourced from maplibre-gl's changelog.

5.6.2

🐞 Bug fixes

5.6.1

🐞 Bug fixes

5.6.0

✨ Features and improvements

🐞 Bug fixes

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=maplibre-gl&package-manager=npm_and_yarn&previous-version=5.5.0&new-version=5.6.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Birk Skyum <74932975+birkskyum@users.noreply.github.com> Co-authored-by: Harel M Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- package-lock.json | 200 +++++++---------------- package.json | 2 +- src/components/App.tsx | 68 +++----- src/components/FieldType.tsx | 19 +-- src/components/LayerEditor.tsx | 97 ++++++++--- src/components/LayerList.tsx | 4 +- src/components/ModalAdd.tsx | 65 ++++---- src/components/_FunctionButtons.tsx | 2 +- src/config/layout.json | 240 ---------------------------- src/libs/non-source-layers.ts | 1 + src/locales/de/translation.json | 16 +- src/locales/fr/translation.json | 18 +-- src/locales/he/translation.json | 9 +- src/locales/it/translation.json | 9 +- src/locales/ja/translation.json | 18 +-- src/locales/zh/translation.json | 18 +-- 16 files changed, 249 insertions(+), 537 deletions(-) delete mode 100644 src/config/layout.json create mode 100644 src/libs/non-source-layers.ts diff --git a/package-lock.json b/package-lock.json index 4fbd134e..0ca7d4da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37,7 +37,7 @@ "lodash.get": "^4.4.2", "lodash.isequal": "^4.5.0", "lodash.throttle": "^4.1.1", - "maplibre-gl": "^5.5.0", + "maplibre-gl": "^5.6.2", "maputnik-design": "github:maputnik/design#172b06c", "ol": "^10.6.1", "ol-mapbox-style": "^13.1.0", @@ -1797,14 +1797,16 @@ "license": "BSD-2-Clause" }, "node_modules/@mapbox/point-geometry": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@mapbox/point-geometry/-/point-geometry-0.1.0.tgz", - "integrity": "sha512-6j56HdLTwWGO0fJPlrZtdU/B13q8Uwmo18Ck2GnGgN9PCFyKTZ3UbXeEdRFh18i9XQ92eH2VdtpJHpBD3aripQ==" + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@mapbox/point-geometry/-/point-geometry-1.1.0.tgz", + "integrity": "sha512-YGcBz1cg4ATXDCM/71L9xveh4dynfGmcLDqufR+nQQy3fKwsAZsWd/x4621/6uJaeB9mwOHE6hPeDgXz9uViUQ==", + "license": "ISC" }, "node_modules/@mapbox/tiny-sdf": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/@mapbox/tiny-sdf/-/tiny-sdf-2.0.6.tgz", - "integrity": "sha512-qMqa27TLw+ZQz5Jk+RcwZGH7BQf5G/TrutJhspsca/3SHwmgKQ1iq+d3Jxz5oysPVYTGP6aXxCo5Lk9Er6YBAA==" + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/@mapbox/tiny-sdf/-/tiny-sdf-2.0.7.tgz", + "integrity": "sha512-25gQLQMcpivjOSA40g3gO6qgiFPDpWRoMfd+G/GoppPIeP6JDaMMkMrEJnMZhKyyS6iKwVt5YKu02vCUyJM3Ug==", + "license": "BSD-2-Clause" }, "node_modules/@mapbox/unitbezier": { "version": "0.0.1", @@ -1812,11 +1814,14 @@ "integrity": "sha512-nMkuDXFv60aBr9soUG5q+GvZYL+2KZHVvsqFCzqnkGEf46U2fvmytHaEVc1/YZbiLn8X+eR3QzX1+dwDO1lxlw==" }, "node_modules/@mapbox/vector-tile": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@mapbox/vector-tile/-/vector-tile-1.3.1.tgz", - "integrity": "sha512-MCEddb8u44/xfQ3oD+Srl/tNcQoqTw3goGk2oLsrFxOTc3dUp+kAnby3PvAeeBYSMSjSPD1nd1AJA6W49WnoUw==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@mapbox/vector-tile/-/vector-tile-2.0.4.tgz", + "integrity": "sha512-AkOLcbgGTdXScosBWwmmD7cDlvOjkg/DetGva26pIRiZPdeJYjYKarIlb4uxVzi6bwHO6EWH82eZ5Nuv4T5DUg==", + "license": "BSD-3-Clause", "dependencies": { - "@mapbox/point-geometry": "~0.1.0" + "@mapbox/point-geometry": "~1.1.0", + "@types/geojson": "^7946.0.16", + "pbf": "^4.0.1" } }, "node_modules/@mapbox/whoots-js": { @@ -1860,9 +1865,9 @@ } }, "node_modules/@maplibre/maplibre-gl-style-spec": { - "version": "23.2.3", - "resolved": "https://registry.npmjs.org/@maplibre/maplibre-gl-style-spec/-/maplibre-gl-style-spec-23.2.3.tgz", - "integrity": "sha512-2PMt4fZEAxm4/uMyS9B4QXOknJ2DpzU3qsFKximwfsmHz4Z1RcWoIEHgOdv7UmDRaM2voDju5/VJdH53IydMqg==", + "version": "23.3.0", + "resolved": "https://registry.npmjs.org/@maplibre/maplibre-gl-style-spec/-/maplibre-gl-style-spec-23.3.0.tgz", + "integrity": "sha512-IGJtuBbaGzOUgODdBRg66p8stnwj9iDXkgbYKoYcNiiQmaez5WVRfXm4b03MCDwmZyX93csbfHFWEJJYHnn5oA==", "license": "ISC", "dependencies": { "@mapbox/jsonlint-lines-primitives": "~2.0.2", @@ -1879,6 +1884,21 @@ "gl-style-validate": "dist/gl-style-validate.mjs" } }, + "node_modules/@maplibre/vt-pbf": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@maplibre/vt-pbf/-/vt-pbf-4.0.3.tgz", + "integrity": "sha512-YsW99BwnT+ukJRkseBcLuZHfITB4puJoxnqPVjo72rhW/TaawVYsgQHcqWLzTxqknttYoDpgyERzWSa/XrETdA==", + "license": "MIT", + "dependencies": { + "@mapbox/point-geometry": "^1.1.0", + "@mapbox/vector-tile": "^2.0.4", + "@types/geojson-vt": "3.2.5", + "@types/supercluster": "^7.1.3", + "geojson-vt": "^4.0.2", + "pbf": "^4.0.1", + "supercluster": "^8.0.1" + } + }, "node_modules/@mdi/js": { "version": "7.4.47", "resolved": "https://registry.npmjs.org/@mdi/js/-/js-7.4.47.tgz", @@ -3028,21 +3048,6 @@ "@types/lodash": "*" } }, - "node_modules/@types/mapbox__point-geometry": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/@types/mapbox__point-geometry/-/mapbox__point-geometry-0.1.4.tgz", - "integrity": "sha512-mUWlSxAmYLfwnRBmgYV86tgYmMIICX4kza8YnE/eIlywGe2XoOxlpVnXWwir92xRLjwyarqwpu2EJKD2pk0IUA==" - }, - "node_modules/@types/mapbox__vector-tile": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/@types/mapbox__vector-tile/-/mapbox__vector-tile-1.3.4.tgz", - "integrity": "sha512-bpd8dRn9pr6xKvuEBQup8pwQfD4VUyqO/2deGjfpe6AwC8YRlyEipvefyRJUSiCJTZuCb8Pl1ciVV5ekqJ96Bg==", - "dependencies": { - "@types/geojson": "*", - "@types/mapbox__point-geometry": "*", - "@types/pbf": "*" - } - }, "node_modules/@types/minimatch": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.5.tgz", @@ -3058,11 +3063,6 @@ "undici-types": "~5.26.4" } }, - "node_modules/@types/pbf": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/@types/pbf/-/pbf-3.0.5.tgz", - "integrity": "sha512-j3pOPiEcWZ34R6a6mN07mUkM4o4Lwf6hPNt8eilOeZhTFbxFXmKhvXl9Y28jotFPaI1bpPDJsbCprUoNke6OrA==" - }, "node_modules/@types/pixelmatch": { "version": "5.2.6", "resolved": "https://registry.npmjs.org/@types/pixelmatch/-/pixelmatch-5.2.6.tgz", @@ -5325,9 +5325,9 @@ } }, "node_modules/earcut": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/earcut/-/earcut-3.0.1.tgz", - "integrity": "sha512-0l1/0gOjESMeQyYaK5IDiPNvFeu93Z/cO0TjZh9eZ1vyCtZnA7KMZ8rQggpsJHIbGSdrqYq9OhuveadOVHCshw==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/earcut/-/earcut-3.0.2.tgz", + "integrity": "sha512-X7hshQbLyMJ/3RPhyObLARM2sNxxmRALLKx1+NVFFnQ9gKzmCrxm9+uLIAdBcvc8FNLpctqlQ2V6AE92Ol9UDQ==", "license": "ISC" }, "node_modules/eastasianwidth": { @@ -8702,6 +8702,7 @@ "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -9057,37 +9058,33 @@ "license": "BSD-2-Clause" }, "node_modules/maplibre-gl": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/maplibre-gl/-/maplibre-gl-5.5.0.tgz", - "integrity": "sha512-p8AOPuzzqn1ZA9gcXxKw0IED715we/2Owa/YUr6PANmgMvNMe/JG+V/C1hRra43Wm62Biz+Aa8AgbOLJimA8tA==", + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/maplibre-gl/-/maplibre-gl-5.6.2.tgz", + "integrity": "sha512-SEqYThhUCFf6Lm0TckpgpKnto5u4JsdPYdFJb6g12VtuaFsm3nYdBO+fOmnUYddc8dXihgoGnuXvPPooUcRv5w==", "license": "BSD-3-Clause", "dependencies": { "@mapbox/geojson-rewind": "^0.5.2", "@mapbox/jsonlint-lines-primitives": "^2.0.2", - "@mapbox/point-geometry": "^0.1.0", - "@mapbox/tiny-sdf": "^2.0.6", + "@mapbox/point-geometry": "^1.1.0", + "@mapbox/tiny-sdf": "^2.0.7", "@mapbox/unitbezier": "^0.0.1", - "@mapbox/vector-tile": "^1.3.1", + "@mapbox/vector-tile": "^2.0.4", "@mapbox/whoots-js": "^3.1.0", - "@maplibre/maplibre-gl-style-spec": "^23.2.2", + "@maplibre/maplibre-gl-style-spec": "^23.3.0", + "@maplibre/vt-pbf": "^4.0.3", "@types/geojson": "^7946.0.16", "@types/geojson-vt": "3.2.5", - "@types/mapbox__point-geometry": "^0.1.4", - "@types/mapbox__vector-tile": "^1.3.4", - "@types/pbf": "^3.0.5", "@types/supercluster": "^7.1.3", - "earcut": "^3.0.1", + "earcut": "^3.0.2", "geojson-vt": "^4.0.2", "gl-matrix": "^3.4.3", - "global-prefix": "^4.0.0", "kdbush": "^4.0.2", "murmurhash-js": "^1.0.0", - "pbf": "^3.3.0", - "potpack": "^2.0.0", + "pbf": "^4.0.1", + "potpack": "^2.1.0", "quickselect": "^3.0.0", "supercluster": "^8.0.1", - "tinyqueue": "^3.0.0", - "vt-pbf": "^3.1.3" + "tinyqueue": "^3.0.0" }, "engines": { "node": ">=16.14.0", @@ -9097,66 +9094,6 @@ "url": "https://github.com/maplibre/maplibre-gl-js?sponsor=1" } }, - "node_modules/maplibre-gl/node_modules/global-prefix": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-4.0.0.tgz", - "integrity": "sha512-w0Uf9Y9/nyHinEk5vMJKRie+wa4kR5hmDbEhGGds/kG1PwGLLHKRoNMeJOyCQjjBkANlnScqgzcFwGHgmgLkVA==", - "license": "MIT", - "dependencies": { - "ini": "^4.1.3", - "kind-of": "^6.0.3", - "which": "^4.0.0" - }, - "engines": { - "node": ">=16" - } - }, - "node_modules/maplibre-gl/node_modules/ini": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/ini/-/ini-4.1.3.tgz", - "integrity": "sha512-X7rqawQBvfdjS10YU1y1YVreA3SsLrW9dX2CewP2EbBJM4ypVNLDkO5y04gejPwKIY9lR+7r9gn3rFPt/kmWFg==", - "license": "ISC", - "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" - } - }, - "node_modules/maplibre-gl/node_modules/isexe": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.1.tgz", - "integrity": "sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ==", - "license": "ISC", - "engines": { - "node": ">=16" - } - }, - "node_modules/maplibre-gl/node_modules/pbf": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/pbf/-/pbf-3.3.0.tgz", - "integrity": "sha512-XDF38WCH3z5OV/OVa8GKUNtLAyneuzbCisx7QUCF8Q6Nutx0WnJrQe5O+kOtBlLfRNUws98Y58Lblp+NJG5T4Q==", - "license": "BSD-3-Clause", - "dependencies": { - "ieee754": "^1.1.12", - "resolve-protobuf-schema": "^2.1.0" - }, - "bin": { - "pbf": "bin/pbf" - } - }, - "node_modules/maplibre-gl/node_modules/which": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/which/-/which-4.0.0.tgz", - "integrity": "sha512-GlaYyEb07DPxYCKhKzplCWBJtvxZcZMrL+4UkrTSJHHPyZU4mYYTv3qaOe77H7EODLSSopAUFAc6W8U4yqvscg==", - "license": "ISC", - "dependencies": { - "isexe": "^3.1.1" - }, - "bin": { - "node-which": "bin/which.js" - }, - "engines": { - "node": "^16.13.0 || >=18.0.0" - } - }, "node_modules/maputnik-design": { "version": "0.1.0", "resolved": "git+ssh://git@github.com/maputnik/design.git#172b06cb062a82f62bb7239474533a110915ef3e" @@ -9870,18 +9807,6 @@ "ol": "*" } }, - "node_modules/ol/node_modules/pbf": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/pbf/-/pbf-4.0.1.tgz", - "integrity": "sha512-SuLdBvS42z33m8ejRbInMapQe8n0D3vN/Xd5fmWM3tufNgRQFBpaW2YVJxQZV4iPNqb0vEFvssMEo5w9c6BTIA==", - "license": "BSD-3-Clause", - "dependencies": { - "resolve-protobuf-schema": "^2.1.0" - }, - "bin": { - "pbf": "bin/pbf" - } - }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -10176,11 +10101,11 @@ } }, "node_modules/pbf": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/pbf/-/pbf-3.2.1.tgz", - "integrity": "sha512-ClrV7pNOn7rtmoQVF4TS1vyU0WhYRnP92fzbfF75jAIwpnzdJXf8iTd4CMEqO4yUenH6NDqLiwjqlh6QgZzgLQ==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/pbf/-/pbf-4.0.1.tgz", + "integrity": "sha512-SuLdBvS42z33m8ejRbInMapQe8n0D3vN/Xd5fmWM3tufNgRQFBpaW2YVJxQZV4iPNqb0vEFvssMEo5w9c6BTIA==", + "license": "BSD-3-Clause", "dependencies": { - "ieee754": "^1.1.12", "resolve-protobuf-schema": "^2.1.0" }, "bin": { @@ -10464,9 +10389,10 @@ "dev": true }, "node_modules/potpack": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/potpack/-/potpack-2.0.0.tgz", - "integrity": "sha512-Q+/tYsFU9r7xoOJ+y/ZTtdVQwTWfzjbiXBDMM/JKUux3+QPP02iUuIoeBQ+Ot6oEDlC+/PGjB/5A3K7KKb7hcw==" + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/potpack/-/potpack-2.1.0.tgz", + "integrity": "sha512-pcaShQc1Shq0y+E7GqJqvZj8DTthWV1KeHGdi0Z6IAin2Oi3JnLCOfwnCo84qc+HAp52wT9nK9H7FAJp5a44GQ==", + "license": "ISC" }, "node_modules/prelude-ls": { "version": "1.2.1", @@ -13342,16 +13268,6 @@ "node": ">=0.10.0" } }, - "node_modules/vt-pbf": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/vt-pbf/-/vt-pbf-3.1.3.tgz", - "integrity": "sha512-2LzDFzt0mZKZ9IpVF2r69G9bXaP2Q2sArJCmcCgvfTdCCZzSyz4aCLoQyUilu37Ll56tCblIZrXFIjNUpGIlmA==", - "dependencies": { - "@mapbox/point-geometry": "0.1.0", - "@mapbox/vector-tile": "^1.3.1", - "pbf": "^3.2.1" - } - }, "node_modules/walk-sync": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/walk-sync/-/walk-sync-2.2.0.tgz", diff --git a/package.json b/package.json index ef0163ae..9763464a 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "lodash.get": "^4.4.2", "lodash.isequal": "^4.5.0", "lodash.throttle": "^4.1.1", - "maplibre-gl": "^5.5.0", + "maplibre-gl": "^5.6.2", "maputnik-design": "github:maputnik/design#172b06c", "ol": "^10.6.1", "ol-mapbox-style": "^13.1.0", diff --git a/src/components/App.tsx b/src/components/App.tsx index da3018e1..e03739c3 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -108,7 +108,7 @@ type AppState = { dirtyMapStyle?: StyleSpecification, selectedLayerIndex: number, selectedLayerOriginalId?: string, - sources: {[key: string]: SourceSpecification}, + sources: {[key: string]: SourceSpecification & {layers: string[]} }, vectorLayers: {}, spec: any, mapView: { @@ -402,7 +402,6 @@ export default class App extends React.Component { } const errors: ValidationError[] = validateStyleMin(newStyle) || []; - // The validate function doesn't give us errors for duplicate error with // empty string for layer.id, manually deal with that here. const layerErrors: (Error | ValidationError)[] = []; @@ -643,21 +642,22 @@ export default class App extends React.Component { this.onStyleChanged(styleObj) } - fetchSources() { - const sourceList: {[key: string]: any} = {}; - - for(const [key, val] of Object.entries(this.state.mapStyle.sources)) { - if( - !Object.prototype.hasOwnProperty.call(this.state.sources, key) && - val.type === "vector" && - Object.prototype.hasOwnProperty.call(val, "url") - ) { + async fetchSources() { + const sourceList: {[key: string]: SourceSpecification & {layers: string[]}} = {}; + for(const key of Object.keys(this.state.mapStyle.sources)) { + const source = this.state.mapStyle.sources[key]; + if(source.type !== "vector" || !('url' in source)) { + sourceList[key] = this.state.sources[key] || {...this.state.mapStyle.sources[key]}; + if (sourceList[key].layers === undefined) { + sourceList[key].layers = []; + } + } else { sourceList[key] = { - type: val.type, + type: source.type, layers: [] }; - let url = val.url; + let url = source.url; try { url = setFetchAccessToken(url!, this.state.mapStyle) @@ -670,44 +670,28 @@ export default class App extends React.Component { return; } - // Create new objects before setState - const sources = Object.assign({}, { - [key]: this.state.sources[key], - }); - for(const layer of json.vector_layers) { - (sources[key] as any).layers.push(layer.id) + sourceList[key].layers.push(layer.id) } - - this.setState({ - sources: sources - }); }; - if (url!.startsWith("pmtiles://")) { - (new PMTiles(url!.substr(10))).getTileJson("") - .then(json => setVectorLayers(json)) - .catch(err => { - console.error("Failed to process sources for '%s'", url, err); - }); - } else { - fetch(url!, { - mode: 'cors', - }) - .then(response => response.json()) - .then(json => setVectorLayers(json)) - .catch(err => { - console.error("Failed to process sources for '%s'", url, err); - }); + try { + if (url!.startsWith("pmtiles://")) { + const json = await (new PMTiles(url!.substring(10))).getTileJson(""); + setVectorLayers(json); + } else { + const response = await fetch(url!, { mode: 'cors' }); + const json = await response.json(); + setVectorLayers(json); + } + } catch(err) { + console.error(`Failed to process source for url: '${url}', ${err}`); } } - else { - sourceList[key] = this.state.sources[key] || this.state.mapStyle.sources[key]; - } } if(!isEqual(this.state.sources, sourceList)) { - console.debug("Setting sources"); + console.debug("Setting sources", sourceList); this.setState({ sources: sourceList }) diff --git a/src/components/FieldType.tsx b/src/components/FieldType.tsx index 535d09b3..f89be9f7 100644 --- a/src/components/FieldType.tsx +++ b/src/components/FieldType.tsx @@ -1,10 +1,10 @@ import React from 'react' - -import latest from '@maplibre/maplibre-gl-style-spec/dist/latest.json' +import {v8} from '@maplibre/maplibre-gl-style-spec' import Block from './Block' import InputSelect from './InputSelect' import InputString from './InputString' import { WithTranslation, withTranslation } from 'react-i18next'; +import { startCase } from 'lodash' type FieldTypeInternalProps = { value: string @@ -16,8 +16,9 @@ type FieldTypeInternalProps = { const FieldTypeInternal: React.FC = (props) => { const t = props.t; + const layerstypes: [string, string][] = Object.keys(v8.layer.type.values || {}).map(v => [v, startCase(v.replace(/-/g, ' '))]); return ( - @@ -26,17 +27,7 @@ const FieldTypeInternal: React.FC = (props) => { )} {!props.disabled && ( { - return { - ...group, - id: group.title.replace(/ /g, "_"), - title: t(group.title) - }; - }), - } : layout.invalid; +function getLayoutForSymbolType(t: TFunction): MaputnikLayoutGroup[] { + const groups: MaputnikLayoutGroup[] = []; + groups.push({ + title: t("General layout properties"), + id: "General_layout_properties", + type: "properties", + fields: Object.keys(v8["layout_symbol"]).filter(f => f.startsWith("symbol-")) + }); + groups.push({ + title: t("Text layout properties"), + id: "Text_layout_properties", + type: "properties", + fields: Object.keys(v8["layout_symbol"]).filter(f => f.startsWith("text-")) + }); + groups.push({ + title: t("Icon layout properties"), + id: "Icon_layout_properties", + type: "properties", + fields: Object.keys(v8["layout_symbol"]).filter(f => f.startsWith("icon-")) + }); + groups.push({ + title: t("Text paint properties"), + id: "Text_paint_properties", + type: "properties", + fields: Object.keys(v8["paint_symbol"]).filter(f => f.startsWith("text-")) + }); + groups.push({ + title: t("Icon paint properties"), + id: "Icon_paint_properties", + type: "properties", + fields: Object.keys(v8["paint_symbol"]).filter(f => f.startsWith("icon-")) + }); + return groups; +} + +function getLayoutForType(type: LayerSpecification["type"], t: TFunction): MaputnikLayoutGroup[] { + if (Object.keys(v8.layer.type.values).indexOf(type) < 0) { + return [] + } + if (type === "symbol") { + return getLayoutForSymbolType(t); + } + const groups: MaputnikLayoutGroup[] = []; + if (Object.keys(v8["paint_" + type]).length > 0) { + groups.push({ + title: t("Paint properties"), + id: "Paint_properties", + type: "properties", + fields: Object.keys(v8["paint_" + type]), + }); + } + if (Object.keys(v8["layout_" + type]).length > 0) { + groups.push({ + title: t("Layout properties"), + id: "Layout_properties", + type: "properties", + fields: Object.keys(v8["layout_" + type]) + }); + } + return groups; } function layoutGroups(layerType: LayerSpecification["type"], t: TFunction): {id: string, title: string, type: string, fields?: string[]}[] { @@ -53,13 +109,13 @@ function layoutGroups(layerType: LayerSpecification["type"], t: TFunction): {id: type: 'jsoneditor' } return [layerGroup, filterGroup] - .concat(getLayoutForType(layerType, t).groups) + .concat(getLayoutForType(layerType, t)) .concat([editorGroup]) } type LayerEditorInternalProps = { layer: LayerSpecification - sources: {[key: string]: SourceSpecification} + sources: {[key: string]: SourceSpecification & {layers: string[]}} vectorLayers: {[key: string]: any} spec: object onLayerChanged(...args: unknown[]): unknown @@ -89,11 +145,10 @@ class LayerEditorInternal extends React.Component { + for (const group of layoutGroups(this.props.layer.type, props.t)) { editorGroups[group.title] = true - }) + } this.state = { editorGroups } } @@ -101,11 +156,11 @@ class LayerEditorInternal extends React.Component, state: LayerEditorState) { const additionalGroups = { ...state.editorGroups } - getLayoutForType(props.layer.type, props.t).groups.forEach(group => { + for (const group of getLayoutForType(props.layer.type, props.t)) { if(!(group.title in additionalGroups)) { additionalGroups[group.title] = true } - }) + } return { editorGroups: additionalGroups @@ -153,7 +208,7 @@ class LayerEditorInternal extends React.Component; if(Object.prototype.hasOwnProperty.call(this.props.sources, layer.source)) { - sourceLayerIds = (this.props.sources[layer.source] as any).layers; + sourceLayerIds = this.props.sources[layer.source].layers; } switch(type) { @@ -180,7 +235,7 @@ class LayerEditorInternal extends React.Component this.changeProperty(null, 'source', v)} /> } - {['background', 'raster', 'hillshade', 'heatmap'].indexOf(this.props.layer.type) < 0 && + {!NON_SOURCE_LAYERS.includes(this.props.layer.type) && ; errors: any[] }; type LayerListContainerInternalProps = LayerListContainerProps & WithTranslation; diff --git a/src/components/ModalAdd.tsx b/src/components/ModalAdd.tsx index edbdfe04..2a19f1c1 100644 --- a/src/components/ModalAdd.tsx +++ b/src/components/ModalAdd.tsx @@ -6,8 +6,9 @@ import FieldType from './FieldType' import FieldId from './FieldId' import FieldSource from './FieldSource' import FieldSourceLayer from './FieldSourceLayer' -import type {LayerSpecification} from 'maplibre-gl' +import type {LayerSpecification, SourceSpecification} from 'maplibre-gl' import { WithTranslation, withTranslation } from 'react-i18next'; +import { NON_SOURCE_LAYERS } from '../libs/non-source-layers' type ModalAddInternalProps = { layers: LayerSpecification[] @@ -15,7 +16,7 @@ type ModalAddInternalProps = { isOpen: boolean onOpenToggle(open: boolean): unknown // A dict of source id's and the available source layers - sources: any + sources: Record; } & WithTranslation; type ModalAddState = { @@ -41,7 +42,7 @@ class ModalAddInternal extends React.Component 0) { + if(Object.keys(props.sources).length > 0) { state.source = Object.keys(this.props.sources)[0]; - state['source-layer'] = this.props.sources[state.source as keyof ModalAddInternalProps["sources"]][0] + const sourceLayers = this.props.sources[state.source].layers || [] + if (sourceLayers.length > 0) { + state['source-layer'] = sourceLayers[0]; + } } this.state = state; } @@ -97,39 +101,26 @@ class ModalAddInternal extends React.Component v.type === 'raster-dem').map(([k, _]) => k); + case 'raster': + return Object.entries(this.props.sources).filter(([_, v]) => v.type === 'raster').map(([k, _]) => k); + case 'heatmap': + case 'circle': + case 'fill': + case 'fill-extrusion': + case 'line': + case 'symbol': + return Object.entries(this.props.sources).filter(([_, v]) => v.type === 'vector' || v.type === 'geojson').map(([k, _]) => k); + default: + return []; } - - for(const [key, val] of Object.entries(this.props.sources) as any) { - const valType = val.type as keyof typeof types; - if(types[valType] && types[valType].indexOf(type) > -1) { - sources.push(key); - } - } - - return sources; } @@ -182,7 +173,7 @@ class ModalAddInternal extends React.Component this.setState({ source: v })} /> } - {['background', 'raster', 'hillshade', 'heatmap'].indexOf(this.state.type) < 0 && + {!NON_SOURCE_LAYERS.includes(this.state.type) && https://": "Protokoll erforderlich: <1>https://", "Must provide protocol: <1>http:// or <3>https://": "Protokoll erforderlich: <1>http:// oder <3>https://", "CORS policy won't allow fetching resources served over http from https, use a <1>https:// domain": "Die CORS-Politik erlaubt es nicht, Ressourcen über http von https zu laden, benutze eine <1>https://-Domain", + "General layout properties": "Allgemeine Layouteigenschaften", + "Text layout properties": "Text-Layouteigenschaften", + "Icon layout properties": "Icon-Layouteigenschaften", + "Text paint properties": "Text-Darstellungseigenschaften", + "Icon paint properties": "Icon-Darstellungseigenschaften", + "Paint properties": "Darstellungseigenschaften", + "Layout properties": "Layouteigenschaften", "Layer": "Ebene", "JSON Editor": "JSON-Editor", "Delete": "Löschen", @@ -72,7 +79,6 @@ "Collapse": "Einklappen", "Expand": "Ausklappen", "Add Layer": "Ebene hinzufügen", - "Layer ID already exists": "Layer-ID existiert bereits", "Search": "Suche", "Zoom:": "Zoom:", "Close popup": "Popup schließen", @@ -80,6 +86,7 @@ "center:": "Zentrum:", "rotation:": "Rotation:", "Close modal": "Modale Fenster schließen", + "Layer ID already exists": "Layer-ID existiert bereits", "Debug": "Debug", "Options": "Optionen", "Save Style": "Stil Speichern", @@ -187,18 +194,11 @@ "Public access token for LocationIQ services.": "Öffentlicher Zugriffstoken für LocationIQ-Dienste.", "Style Renderer": "Stil-Renderer", "Choose the default Maputnik renderer for this style.": "Wähle den Standard-Renderer für diesen Stil aus.", - "Paint properties": "Darstellungseigenschaften", "Opacity": "Deckkraft", "Radius": "Radius", - "Text paint properties": "Text-Darstellungseigenschaften", - "Icon paint properties": "Icon-Darstellungseigenschaften", - "Text layout properties": "Text-Layouteigenschaften", - "Icon layout properties": "Icon-Layouteigenschaften", - "General layout properties": "Allgemeine Layouteigenschaften", "Color": "Farbe", "Outline color": "Umrissfarbe", "Language": "Sprache", - "Layout properties": "Layouteigenschaften", "Width": "Breite", "Height": "Höhe", "Field": "Feld", diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.json index 7848a57f..193c5f30 100644 --- a/src/locales/fr/translation.json +++ b/src/locales/fr/translation.json @@ -59,6 +59,13 @@ "Must provide protocol: <1>https://": "Protocole requis : <1>https://", "Must provide protocol: <1>http:// or <3>https://": "Protocole requis : <1>http:// ou <3>https://", "CORS policy won't allow fetching resources served over http from https, use a <1>https:// domain": "La politique CORS ne permet pas de récupérer des ressources servies sur http depuis https, utilisez un protocole <1>https://", + "General layout properties": "Propriétés générales de mise en page", + "Text layout properties": "Propriétés de mise en page du texte", + "Icon layout properties": "Propriétés de mise en page de l'icône", + "Text paint properties": "Propriétés de peinture du texte", + "Icon paint properties": "Propriétés de peinture de l'icône", + "Paint properties": "Propriétés de peinture", + "Layout properties": "Propriétés de mise en page", "Layer": "Calque", "JSON Editor": "Éditeur JSON", "Delete": "Supprimer", @@ -72,7 +79,6 @@ "Collapse": "Réduire", "Expand": "Développer", "Add Layer": "Ajouter un calque", - "Layer ID already exists": "L'identifiant du calque existe déjà", "Search": "Recherche", "Zoom:": "Zoom :", "Close popup": "Fermer la fenêtre", @@ -80,6 +86,7 @@ "center:": "centre :", "rotation:": "rotation :", "Close modal": "Fermer la fenêtre modale", + "Layer ID already exists": "L'identifiant du calque existe déjà", "Debug": "Déboguer", "Options": "Options", "Save Style": "Enregistrer le style", @@ -188,12 +195,5 @@ "Style Renderer": "Moteur de rendu pour le style", "Choose the default Maputnik renderer for this style.": "Choisissez le moteur de rendu Maputnik par défaut pour ce style.", "Language": "Langue", - "Layer options": "Options du calque", - "Paint properties": "Propriétés de peinture", - "Layout properties": "Propriétés de mise en page", - "General layout properties": "Propriétés générales de mise en page", - "Text layout properties": "Propriétés de mise en page du texte", - "Icon layout properties": "Propriétés de mise en page de l'icône", - "Text paint properties": "Propriétés de peinture du texte", - "Icon paint properties": "Propriétés de peinture de l'icône" + "Layer options": "Options du calque" } diff --git a/src/locales/he/translation.json b/src/locales/he/translation.json index 47d86f48..996ed0d3 100644 --- a/src/locales/he/translation.json +++ b/src/locales/he/translation.json @@ -59,6 +59,13 @@ "Must provide protocol: <1>https://": "נדרש פרוטוקול: <1>https://", "Must provide protocol: <1>http:// or <3>https://": "נדרשים פרוטוקולים: <1>http:// או <3>https://", "CORS policy won't allow fetching resources served over http from https, use a <1>https:// domain": "CORS policy won't allow fetching resources served over http from https, use a <1>https:// domain", + "General layout properties": "תכונות פריסה כלליות", + "Text layout properties": "תכונות פריסה של טקסט", + "Icon layout properties": "תכונות פריסה של סמליל", + "Text paint properties": "תכונות ציור של טקסט", + "Icon paint properties": "תכונות ציור של סמליל", + "Paint properties": "תכונות ציור", + "Layout properties": "תכונות פריסה", "Layer": "שכבה", "JSON Editor": "עורך JSON", "Delete": "מחיקה", @@ -72,7 +79,6 @@ "Collapse": "הקטנה", "Expand": "הגדלה", "Add Layer": "הוספת שכבה", - "Layer ID already exists": "מזהה השכבה כבר קיים", "Search": "חיפוש", "Zoom:": "זום:", "Close popup": "סגירת החלון", @@ -80,6 +86,7 @@ "center:": "מרכז:", "rotation:": "סיבוב:", "Close modal": "סגירת חלונית", + "Layer ID already exists": "מזהה השכבה כבר קיים", "Debug": "דיבאג", "Options": "אפשרויות", "Save Style": "שמירת הסטייל", diff --git a/src/locales/it/translation.json b/src/locales/it/translation.json index 7be65e5e..7ba9b9c6 100644 --- a/src/locales/it/translation.json +++ b/src/locales/it/translation.json @@ -59,6 +59,13 @@ "Must provide protocol: <1>https://": "Protocollo richiesto: <1>https://", "Must provide protocol: <1>http:// or <3>https://": "Protocollo richiesto: <1>http:// o <3>https://", "CORS policy won't allow fetching resources served over http from https, use a <1>https:// domain": "La politica CORS non permette di caricare risorse tramite http da https, utilizza un dominio <1>https://.", + "General layout properties": "Proprietà generali del layout", + "Text layout properties": "Proprietà di layout del testo", + "Icon layout properties": "Proprietà di layout dell'icona", + "Text paint properties": "Proprietà di pittura del testo", + "Icon paint properties": "Proprietà di pittura dell'icona", + "Paint properties": "Proprietà di pittura", + "Layout properties": "Proprietà di layout", "Layer": "Livello", "JSON Editor": "Editor JSON", "Delete": "Elimina", @@ -72,7 +79,6 @@ "Collapse": "Coprimi", "Expand": "Espandi", "Add Layer": "Aggiungi Livello", - "Layer ID already exists": "L'ID del layer esiste già", "Search": "Cerca", "Zoom:": "Zoom:", "Close popup": "Chiudi popup", @@ -80,6 +86,7 @@ "center:": "centro:", "rotation:": "rotazione:", "Close modal": "Chiudi finestra modale", + "Layer ID already exists": "L'ID del layer esiste già", "Debug": "Debug", "Options": "Opzioni", "Save Style": "Opzioni stile", diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.json index 293f60a9..97b992c5 100644 --- a/src/locales/ja/translation.json +++ b/src/locales/ja/translation.json @@ -59,6 +59,13 @@ "Must provide protocol: <1>https://": "プロトコルを指定してください: <1>https://", "Must provide protocol: <1>http:// or <3>https://": "プロトコルを指定してください: <1>http:// または <3>https://", "CORS policy won't allow fetching resources served over http from https, use a <1>https:// domain": "CORS使用時は、http経由で提供されるリソースをhttpsから取得することはできません。<1>https:// ドメインを使用してください。", + "General layout properties": "一般レイアウトプロパティ", + "Text layout properties": "文字レイアウトプロパティ", + "Icon layout properties": "アイコンレイアウトプロパティ", + "Text paint properties": "文字ペイントプロパティ", + "Icon paint properties": "アイコンペイントプロパティ", + "Paint properties": "ペイントプロパティ", + "Layout properties": "レイアウトプロパティ", "Layer": "レイヤー", "JSON Editor": "JSONエディタ", "Delete": "削除", @@ -72,7 +79,6 @@ "Collapse": "畳む", "Expand": "展開", "Add Layer": "レイヤー追加", - "Layer ID already exists": "レイヤーIDは既に存在します", "Search": "検索", "Zoom:": "ズーム:", "Close popup": "ポップアップを閉じる", @@ -80,6 +86,7 @@ "center:": "中央:", "rotation:": "回転角度:", "Close modal": "モーダルを閉じる", + "Layer ID already exists": "レイヤーIDは既に存在します", "Debug": "デバッグ", "Options": "設定", "Save Style": "スタイルを保存", @@ -189,12 +196,5 @@ "Choose the default Maputnik renderer for this style.": "このスタイルのデフォルトの Maputnik レンダラを選択してください", "Language": "言語", "<0>Open in OSM — Opens the current view on openstreetmap.org": "現在のビューを <0>openstreetmap.org で開く", - "Layer options": "レイヤー設定", - "Paint properties": "ペイントプロパティ", - "Layout properties": "レイアウトプロパティ", - "General layout properties": "一般レイアウトプロパティ", - "Text layout properties": "文字レイアウトプロパティ", - "Icon layout properties": "アイコンレイアウトプロパティ", - "Text paint properties": "文字ペイントプロパティ", - "Icon paint properties": "アイコンペイントプロパティ" + "Layer options": "レイヤー設定" } diff --git a/src/locales/zh/translation.json b/src/locales/zh/translation.json index 9a475134..9516021a 100644 --- a/src/locales/zh/translation.json +++ b/src/locales/zh/translation.json @@ -59,6 +59,13 @@ "Must provide protocol: <1>https://": "必须提供协议:<1>https://", "Must provide protocol: <1>http:// or <3>https://": "必须提供协议:<1>http:// 或 <3>https://", "CORS policy won't allow fetching resources served over http from https, use a <1>https:// domain": "CORS 策略不允许从 https 访问通过 http 提供的资源,请使用 <1>https:// 域名。", + "General layout properties": "常规布局属性", + "Text layout properties": "文本布局属性", + "Icon layout properties": "图标布局属性", + "Text paint properties": "文本绘制属性", + "Icon paint properties": "图标绘制属性", + "Paint properties": "绘制属性", + "Layout properties": "布局属性", "Layer": "图层", "JSON Editor": "JSON编辑器", "Delete": "删除", @@ -72,7 +79,6 @@ "Collapse": "折叠", "Expand": "展开", "Add Layer": "添加图层", - "Layer ID already exists": "图层ID已存在", "Search": "搜索", "Zoom:": "缩放:", "Close popup": "关闭弹出窗口", @@ -80,6 +86,7 @@ "center:": "中心:", "rotation:": "旋转:", "Close modal": "关闭模态框", + "Layer ID already exists": "图层ID已存在", "Debug": "调试", "Options": "选项", "Save Style": "保存样式", @@ -189,12 +196,5 @@ "Choose the default Maputnik renderer for this style.": "为这种样式选择默认的Maputnik渲染器。", "Language": "语言", "<0>Open in OSM — Opens the current view on openstreetmap.org": "在 openstreetmap.org 打开当前视图", - "Layer options": "图层选项", - "Paint properties": "绘制属性", - "Layout properties": "布局属性", - "General layout properties": "常规布局属性", - "Text layout properties": "文本布局属性", - "Icon layout properties": "图标布局属性", - "Text paint properties": "文本绘制属性", - "Icon paint properties": "图标绘制属性" + "Layer options": "图层选项" }