@geolonia/embed 5.0.0 → 5.0.2
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/.github/workflows/build.yml +16 -14
- package/.nvmrc +1 -1
- package/.prettierrc.json +4 -0
- package/.tool-versions +1 -1
- package/README.md +7 -1
- package/dist/embed +1 -1
- package/dist/embed-chunks/2489af4328c51b71e92d.js +2 -0
- package/dist/embed-chunks/6e05bbf5f391fda5b858.js +1 -0
- package/dist/embed.js +1 -1
- package/dist/src/embed.d.ts +3 -1
- package/dist/src/lib/geolonia-map.d.ts +1 -2
- package/dist/src/lib/geolonia-marker.d.ts +1 -2
- package/dist/src/lib/util.d.ts +1 -0
- package/dist/src/version.d.ts +1 -1
- package/e2e/map.spec.ts +1 -1
- package/eslint.config.js +232 -0
- package/package.json +19 -10
- package/src/embed.ts +13 -7
- package/src/lib/CustomAttributionControl.ts +52 -29
- package/src/lib/geolonia-map.ts +126 -39
- package/src/lib/geolonia-marker.ts +9 -6
- package/src/lib/keyring.test.ts +18 -0
- package/src/lib/keyring.ts +11 -13
- package/src/lib/maplibre-util.ts +31 -19
- package/src/lib/parse-atts.test.ts +2 -3
- package/src/lib/render.ts +18 -7
- package/src/lib/simplestyle-vector.ts +42 -13
- package/src/lib/simplestyle.test.ts +80 -69
- package/src/lib/simplestyle.ts +55 -34
- package/src/lib/util.test.ts +71 -22
- package/src/lib/util.ts +88 -32
- package/src/testability.test.ts +7 -4
- package/webpack.config.js +10 -1
- package/.eslintignore +0 -3
- package/.eslintrc.js +0 -17
- package/.prettierrc.js +0 -1
- package/dist/embed-chunks/416af3373e37004e65f4.js +0 -1
- package/dist/embed-chunks/488aacb380a87ea633f6.js +0 -2
- /package/dist/embed-chunks/{488aacb380a87ea633f6.js.LICENSE.txt → 2489af4328c51b71e92d.js.LICENSE.txt} +0 -0
package/dist/src/embed.d.ts
CHANGED
|
@@ -42,7 +42,9 @@ export type EmbedAttributes = {
|
|
|
42
42
|
};
|
|
43
43
|
export type EmbedPlugin<PluginAttributes extends {
|
|
44
44
|
[otherKey: string]: string;
|
|
45
|
-
} = {
|
|
45
|
+
} = {
|
|
46
|
+
[otherKey: string]: string;
|
|
47
|
+
}> = (map: GeoloniaMap, target: HTMLElement, atts: EmbedAttributes & PluginAttributes) => void;
|
|
46
48
|
export type Geolonia = Partial<typeof maplibregl> & {
|
|
47
49
|
accessToken?: string;
|
|
48
50
|
embedVersion: string;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import maplibregl from 'maplibre-gl';
|
|
1
|
+
import maplibregl, { MapOptions, StyleOptions, StyleSpecification, StyleSwapOptions, GetResourceResponse } from 'maplibre-gl';
|
|
2
2
|
import { GetImageCallback } from './util';
|
|
3
|
-
import type { MapOptions, StyleOptions, StyleSpecification, StyleSwapOptions, GetResourceResponse } from 'maplibre-gl';
|
|
4
3
|
export type GeoloniaMapOptions = MapOptions & {
|
|
5
4
|
interactive?: boolean;
|
|
6
5
|
};
|
package/dist/src/lib/util.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export type GetImageCallback = (error?: Error | null, image?: HTMLImageElement |
|
|
|
6
6
|
* @return {string|false} Resolved URL or false if not resolved
|
|
7
7
|
*/
|
|
8
8
|
export declare function isURL(str: string): string | false;
|
|
9
|
+
export declare function isGeoloniaTilesHost(url: string | URL): boolean;
|
|
9
10
|
export declare function checkPermission(): boolean;
|
|
10
11
|
export declare function getLang(): "ja" | "en";
|
|
11
12
|
/**
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "5.0.
|
|
1
|
+
export declare const VERSION = "5.0.2";
|
package/e2e/map.spec.ts
CHANGED
package/eslint.config.js
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
const {
|
|
2
|
+
defineConfig,
|
|
3
|
+
globalIgnores,
|
|
4
|
+
} = require("eslint/config");
|
|
5
|
+
|
|
6
|
+
const globals = require("globals");
|
|
7
|
+
const _import = require("eslint-plugin-import");
|
|
8
|
+
const promise = require("eslint-plugin-promise");
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
fixupPluginRules,
|
|
12
|
+
fixupConfigRules,
|
|
13
|
+
} = require("@eslint/compat");
|
|
14
|
+
|
|
15
|
+
const tsParser = require("@typescript-eslint/parser");
|
|
16
|
+
const react = require("eslint-plugin-react");
|
|
17
|
+
const reactHooks = require("eslint-plugin-react-hooks");
|
|
18
|
+
const js = require("@eslint/js");
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
FlatCompat,
|
|
22
|
+
} = require("@eslint/eslintrc");
|
|
23
|
+
|
|
24
|
+
const compat = new FlatCompat({
|
|
25
|
+
baseDirectory: __dirname,
|
|
26
|
+
recommendedConfig: js.configs.recommended,
|
|
27
|
+
allConfig: js.configs.all
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
module.exports = defineConfig([{
|
|
31
|
+
extends: compat.extends(
|
|
32
|
+
"eslint:recommended",
|
|
33
|
+
"plugin:promise/recommended",
|
|
34
|
+
),
|
|
35
|
+
|
|
36
|
+
languageOptions: {
|
|
37
|
+
globals: {
|
|
38
|
+
...globals.browser,
|
|
39
|
+
...globals.commonjs,
|
|
40
|
+
...globals.node,
|
|
41
|
+
...globals.mocha,
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
sourceType: "module",
|
|
45
|
+
|
|
46
|
+
parserOptions: {
|
|
47
|
+
project: "./tsconfig.json",
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
plugins: {
|
|
52
|
+
import: fixupPluginRules(_import),
|
|
53
|
+
promise,
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
rules: {
|
|
57
|
+
"array-callback-return": "error",
|
|
58
|
+
"arrow-parens": "error",
|
|
59
|
+
"arrow-spacing": "error",
|
|
60
|
+
"block-spacing": "error",
|
|
61
|
+
"key-spacing": "error",
|
|
62
|
+
"keyword-spacing": "error",
|
|
63
|
+
"generator-star-spacing": "error",
|
|
64
|
+
"no-console": "warn",
|
|
65
|
+
"no-useless-computed-key": "error",
|
|
66
|
+
"no-useless-rename": "error",
|
|
67
|
+
"no-var": "error",
|
|
68
|
+
"prefer-arrow-callback": "error",
|
|
69
|
+
"prefer-const": "error",
|
|
70
|
+
"prefer-rest-params": "error",
|
|
71
|
+
"prefer-spread": "error",
|
|
72
|
+
"prefer-template": "error",
|
|
73
|
+
"rest-spread-spacing": "error",
|
|
74
|
+
"semi-spacing": "error",
|
|
75
|
+
"sort-imports": "off",
|
|
76
|
+
"space-before-blocks": "error",
|
|
77
|
+
"template-curly-spacing": "error",
|
|
78
|
+
"yield-star-spacing": "error",
|
|
79
|
+
|
|
80
|
+
yoda: ["error", "never", {
|
|
81
|
+
exceptRange: true,
|
|
82
|
+
}],
|
|
83
|
+
|
|
84
|
+
"import/no-extraneous-dependencies": ["warn", {
|
|
85
|
+
"devDependencies": [
|
|
86
|
+
"**/.eslintrc.js",
|
|
87
|
+
"**/.eslintrc.cjs",
|
|
88
|
+
"**/.mocharc.js",
|
|
89
|
+
"**/.prettierrc.js",
|
|
90
|
+
"**/jest.config.js",
|
|
91
|
+
"**/next.config.js",
|
|
92
|
+
"**/vite.config.js",
|
|
93
|
+
"**/vite.config.ts",
|
|
94
|
+
"**/webpack.config.js",
|
|
95
|
+
],
|
|
96
|
+
}],
|
|
97
|
+
|
|
98
|
+
"promise/prefer-await-to-then": "error",
|
|
99
|
+
},
|
|
100
|
+
}, {
|
|
101
|
+
files: ["**/*.js", "**/*.cjs", "**/*.mjs", "**/*.jsx"],
|
|
102
|
+
|
|
103
|
+
rules: {
|
|
104
|
+
"comma-dangle": ["error", "always-multiline"],
|
|
105
|
+
|
|
106
|
+
"comma-spacing": ["error", {
|
|
107
|
+
before: false,
|
|
108
|
+
after: true,
|
|
109
|
+
}],
|
|
110
|
+
|
|
111
|
+
"no-duplicate-imports": "error",
|
|
112
|
+
"no-useless-constructor": "error",
|
|
113
|
+
|
|
114
|
+
"no-unused-vars": ["warn", {
|
|
115
|
+
argsIgnorePattern: "^_",
|
|
116
|
+
}],
|
|
117
|
+
|
|
118
|
+
quotes: ["error", "single"],
|
|
119
|
+
semi: ["error", "always"],
|
|
120
|
+
"no-loss-of-precision": "off",
|
|
121
|
+
},
|
|
122
|
+
}, {
|
|
123
|
+
files: ["**/*.cjs"],
|
|
124
|
+
|
|
125
|
+
languageOptions: {
|
|
126
|
+
sourceType: "script",
|
|
127
|
+
parserOptions: {},
|
|
128
|
+
},
|
|
129
|
+
}, {
|
|
130
|
+
files: ["**/*.mjs", "**/*.jsx"],
|
|
131
|
+
|
|
132
|
+
languageOptions: {
|
|
133
|
+
sourceType: "module",
|
|
134
|
+
parserOptions: {},
|
|
135
|
+
},
|
|
136
|
+
}, {
|
|
137
|
+
files: ["**/*.ts", "**/*.tsx"],
|
|
138
|
+
extends: compat.extends("plugin:@typescript-eslint/recommended"),
|
|
139
|
+
|
|
140
|
+
languageOptions: {
|
|
141
|
+
parser: tsParser,
|
|
142
|
+
sourceType: "module",
|
|
143
|
+
parserOptions: {},
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
rules: {
|
|
147
|
+
"@typescript-eslint/ban-ts-comment": ["off", {
|
|
148
|
+
"ts-ignore": true,
|
|
149
|
+
}],
|
|
150
|
+
|
|
151
|
+
"comma-dangle": ["error", "always-multiline"],
|
|
152
|
+
|
|
153
|
+
"comma-spacing": ["error", {
|
|
154
|
+
before: false,
|
|
155
|
+
after: true,
|
|
156
|
+
}],
|
|
157
|
+
|
|
158
|
+
"no-duplicate-imports": "error",
|
|
159
|
+
"@typescript-eslint/no-useless-constructor": "error",
|
|
160
|
+
|
|
161
|
+
"@typescript-eslint/no-unused-vars": ["warn", {
|
|
162
|
+
argsIgnorePattern: "^_",
|
|
163
|
+
}],
|
|
164
|
+
|
|
165
|
+
"quotes": ["error", "single", {
|
|
166
|
+
"avoidEscape": true,
|
|
167
|
+
}],
|
|
168
|
+
"semi": ["error", "always"],
|
|
169
|
+
|
|
170
|
+
"@typescript-eslint/no-misused-promises": ["warn", {
|
|
171
|
+
"checksConditionals": true,
|
|
172
|
+
"checksVoidReturn": false,
|
|
173
|
+
}],
|
|
174
|
+
|
|
175
|
+
"@typescript-eslint/ban-types": "off",
|
|
176
|
+
"@typescript-eslint/camelcase": "off",
|
|
177
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
178
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
179
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
180
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
181
|
+
"@typescript-eslint/no-extra-semi": "off",
|
|
182
|
+
"@typescript-eslint/no-loss-of-precision": "off",
|
|
183
|
+
"@typescript-eslint/no-this-alias": "off",
|
|
184
|
+
"@typescript-eslint/no-var-requires": "off",
|
|
185
|
+
},
|
|
186
|
+
}, {
|
|
187
|
+
files: ["**/*.jsx", "**/*.tsx"],
|
|
188
|
+
|
|
189
|
+
extends: fixupConfigRules(
|
|
190
|
+
compat.extends("plugin:react/recommended", "plugin:react-hooks/recommended"),
|
|
191
|
+
),
|
|
192
|
+
|
|
193
|
+
languageOptions: {
|
|
194
|
+
globals: {
|
|
195
|
+
...globals.browser,
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
plugins: {
|
|
200
|
+
react: fixupPluginRules(react),
|
|
201
|
+
"react-hooks": fixupPluginRules(reactHooks),
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
settings: {
|
|
205
|
+
react: {
|
|
206
|
+
pragma: "React",
|
|
207
|
+
version: "detect",
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
|
|
211
|
+
rules: {
|
|
212
|
+
"react/jsx-uses-react": "off",
|
|
213
|
+
"react/prop-types": "off",
|
|
214
|
+
"react/react-in-jsx-scope": "off",
|
|
215
|
+
},
|
|
216
|
+
}, {
|
|
217
|
+
files: [
|
|
218
|
+
"**/*.test.js",
|
|
219
|
+
"**/*.test.ts",
|
|
220
|
+
"**/*.test.jsx",
|
|
221
|
+
"**/*.test.tsx",
|
|
222
|
+
"**/*.spec.js",
|
|
223
|
+
"**/*.spec.ts",
|
|
224
|
+
"**/*.spec.jsx",
|
|
225
|
+
"**/*.spec.tsx",
|
|
226
|
+
],
|
|
227
|
+
|
|
228
|
+
rules: {
|
|
229
|
+
"no-import-assign": "off",
|
|
230
|
+
"import/no-extraneous-dependencies": "off",
|
|
231
|
+
},
|
|
232
|
+
}, globalIgnores(["node_modules/", "docs", "dist", "eslint.config.js", ".*.js"])]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geolonia/embed",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "Geolonia embed JS API",
|
|
5
5
|
"main": "dist/embed.js",
|
|
6
6
|
"types": "dist/embed.d.ts",
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
"start": "webpack serve --config ./docs/webpack.config.js",
|
|
11
11
|
"build": "npm run build:version && npm run build:embed",
|
|
12
12
|
"build:version": "node ./scripts/build-version.mjs",
|
|
13
|
-
"build:embed": "webpack --mode production && cp ./dist/embed.js ./dist/embed && cp -r ./dist/* ./docs/ && rm -rf ./docs/*.d.ts ./docs/lib/",
|
|
14
|
-
"analyze": "ANALYZE=true webpack --mode production",
|
|
15
|
-
"format": "prettier
|
|
16
|
-
"lint": "eslint
|
|
17
|
-
"test": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha",
|
|
13
|
+
"build:embed": "MAP_PLATFORM_STAGE=v1 webpack --mode production && cp ./dist/embed.js ./dist/embed && cp -r ./dist/* ./docs/ && rm -rf ./docs/*.d.ts ./docs/lib/",
|
|
14
|
+
"analyze": "ANALYZE=true MAP_PLATFORM_STAGE=v1 webpack --mode production",
|
|
15
|
+
"format": "prettier \"./src/**/*.ts\" --write",
|
|
16
|
+
"lint": "eslint .",
|
|
17
|
+
"test": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' NODE_OPTIONS=\"--no-experimental-strip-types\" mocha",
|
|
18
18
|
"e2e": "playwright test"
|
|
19
19
|
},
|
|
20
20
|
"author": "Geolonia (https://geolonia.com)",
|
|
@@ -28,19 +28,28 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/geolonia/embed#readme",
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@
|
|
31
|
+
"@eslint/compat": "^1.4.1",
|
|
32
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
33
|
+
"@eslint/js": "^9.39.1",
|
|
32
34
|
"@types/jsdom": "^21.1.7",
|
|
33
35
|
"@types/mocha": "^10.0.1",
|
|
34
36
|
"@types/node": "^24.0.4",
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "^8.46.4",
|
|
38
|
+
"@typescript-eslint/parser": "^8.46.4",
|
|
35
39
|
"babel-loader": "^9.1.0",
|
|
36
40
|
"css-loader": "^6.7.2",
|
|
37
|
-
"eslint": "^
|
|
41
|
+
"eslint": "^9.39.1",
|
|
42
|
+
"eslint-config-prettier": "^10.1.8",
|
|
43
|
+
"eslint-plugin-import": "^2.32.0",
|
|
44
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
45
|
+
"eslint-plugin-react": "^7.37.5",
|
|
46
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
47
|
+
"globals": "^16.5.0",
|
|
38
48
|
"jsdom": "^20.0.3",
|
|
39
49
|
"jsdom-global": "^3.0.2",
|
|
40
50
|
"mocha": "^10.2.0",
|
|
41
51
|
"node-fetch": "2",
|
|
42
|
-
"prettier
|
|
43
|
-
"prettier-eslint-cli": "^7.1.0",
|
|
52
|
+
"prettier": "^3.6.2",
|
|
44
53
|
"style-loader": "^3.3.1",
|
|
45
54
|
"svg-inline-loader": "^0.8.2",
|
|
46
55
|
"ts-loader": "^9.4.3",
|
package/src/embed.ts
CHANGED
|
@@ -46,7 +46,15 @@ export type EmbedAttributes = {
|
|
|
46
46
|
[otherKey: string]: string;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
export type EmbedPlugin<
|
|
49
|
+
export type EmbedPlugin<
|
|
50
|
+
PluginAttributes extends { [otherKey: string]: string } = {
|
|
51
|
+
[otherKey: string]: string;
|
|
52
|
+
},
|
|
53
|
+
> = (
|
|
54
|
+
map: GeoloniaMap,
|
|
55
|
+
target: HTMLElement,
|
|
56
|
+
atts: EmbedAttributes & PluginAttributes,
|
|
57
|
+
) => void;
|
|
50
58
|
|
|
51
59
|
// Type for `window.geolonia`
|
|
52
60
|
export type Geolonia = Partial<typeof maplibregl> & {
|
|
@@ -61,9 +69,9 @@ export type Geolonia = Partial<typeof maplibregl> & {
|
|
|
61
69
|
|
|
62
70
|
declare global {
|
|
63
71
|
interface Window {
|
|
64
|
-
geolonia: Geolonia
|
|
65
|
-
maplibregl?: Geolonia
|
|
66
|
-
mapboxgl?: Geolonia
|
|
72
|
+
geolonia: Geolonia;
|
|
73
|
+
maplibregl?: Geolonia;
|
|
74
|
+
mapboxgl?: Geolonia;
|
|
67
75
|
}
|
|
68
76
|
}
|
|
69
77
|
|
|
@@ -76,9 +84,7 @@ const geolonia: Geolonia = Object.assign(window.geolonia || {}, maplibregl, {
|
|
|
76
84
|
registerPlugin,
|
|
77
85
|
});
|
|
78
86
|
|
|
79
|
-
window.geolonia =
|
|
80
|
-
(window.maplibregl as any) =
|
|
81
|
-
window.mapboxgl = geolonia;
|
|
87
|
+
window.geolonia = (window.maplibregl as any) = window.mapboxgl = geolonia;
|
|
82
88
|
|
|
83
89
|
renderGeoloniaMap();
|
|
84
90
|
|
|
@@ -40,23 +40,16 @@ class CustomAttributionControl implements IControl {
|
|
|
40
40
|
|
|
41
41
|
constructor(options = {}) {
|
|
42
42
|
this.options = options;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
bindAll([
|
|
55
|
-
'_toggleAttribution',
|
|
56
|
-
'_updateData',
|
|
57
|
-
'_updateCompact',
|
|
58
|
-
'_updateCompactMinimize',
|
|
59
|
-
], this);
|
|
43
|
+
|
|
44
|
+
bindAll(
|
|
45
|
+
[
|
|
46
|
+
'_toggleAttribution',
|
|
47
|
+
'_updateData',
|
|
48
|
+
'_updateCompact',
|
|
49
|
+
'_updateCompactMinimize',
|
|
50
|
+
],
|
|
51
|
+
this,
|
|
52
|
+
);
|
|
60
53
|
}
|
|
61
54
|
|
|
62
55
|
getDefaultPosition(): ControlPosition {
|
|
@@ -68,13 +61,24 @@ class CustomAttributionControl implements IControl {
|
|
|
68
61
|
this._compact = this.options && this.options.compact;
|
|
69
62
|
this._container = DOM.create('div');
|
|
70
63
|
|
|
71
|
-
const shadow = this._container.attachShadow({mode: 'open'});
|
|
72
|
-
|
|
73
|
-
this._shadowContainer = DOM.create(
|
|
74
|
-
|
|
64
|
+
const shadow = this._container.attachShadow({ mode: 'open' });
|
|
65
|
+
|
|
66
|
+
this._shadowContainer = DOM.create(
|
|
67
|
+
'details',
|
|
68
|
+
'maplibregl-ctrl maplibregl-ctrl-attrib',
|
|
69
|
+
);
|
|
70
|
+
this._compactButton = DOM.create(
|
|
71
|
+
'summary',
|
|
72
|
+
'maplibregl-ctrl-attrib-button',
|
|
73
|
+
this._shadowContainer,
|
|
74
|
+
);
|
|
75
75
|
this._compactButton.addEventListener('click', this._toggleAttribution);
|
|
76
76
|
this._setElementTitle(this._compactButton, 'ToggleAttribution');
|
|
77
|
-
this._innerContainer = DOM.create(
|
|
77
|
+
this._innerContainer = DOM.create(
|
|
78
|
+
'div',
|
|
79
|
+
'maplibregl-ctrl-attrib-inner',
|
|
80
|
+
this._shadowContainer,
|
|
81
|
+
);
|
|
78
82
|
|
|
79
83
|
const style = document.createElement('style');
|
|
80
84
|
style.textContent = `
|
|
@@ -274,7 +278,13 @@ class CustomAttributionControl implements IControl {
|
|
|
274
278
|
}
|
|
275
279
|
|
|
276
280
|
_updateData(e) {
|
|
277
|
-
if (
|
|
281
|
+
if (
|
|
282
|
+
e &&
|
|
283
|
+
(e.sourceDataType === 'metadata' ||
|
|
284
|
+
e.sourceDataType === 'visibility' ||
|
|
285
|
+
e.dataType === 'style' ||
|
|
286
|
+
e.type === 'terrain')
|
|
287
|
+
) {
|
|
278
288
|
this._updateAttributions();
|
|
279
289
|
}
|
|
280
290
|
}
|
|
@@ -306,7 +316,10 @@ class CustomAttributionControl implements IControl {
|
|
|
306
316
|
const sourceCache = sourceCaches[id];
|
|
307
317
|
if (sourceCache.used || sourceCache.usedForTerrain) {
|
|
308
318
|
const source = sourceCache.getSource();
|
|
309
|
-
if (
|
|
319
|
+
if (
|
|
320
|
+
source.attribution &&
|
|
321
|
+
attributions.indexOf(source.attribution) < 0
|
|
322
|
+
) {
|
|
310
323
|
attributions.push(source.attribution);
|
|
311
324
|
}
|
|
312
325
|
}
|
|
@@ -320,7 +333,9 @@ class CustomAttributionControl implements IControl {
|
|
|
320
333
|
attributions.sort((a, b) => a.length - b.length);
|
|
321
334
|
attributions = attributions.filter((attrib, i) => {
|
|
322
335
|
for (let j = i + 1; j < attributions.length; j++) {
|
|
323
|
-
if (attributions[j].indexOf(attrib) >= 0) {
|
|
336
|
+
if (attributions[j].indexOf(attrib) >= 0) {
|
|
337
|
+
return false;
|
|
338
|
+
}
|
|
324
339
|
}
|
|
325
340
|
return true;
|
|
326
341
|
});
|
|
@@ -346,14 +361,23 @@ class CustomAttributionControl implements IControl {
|
|
|
346
361
|
if (this._map.getCanvasContainer().offsetWidth <= 640 || this._compact) {
|
|
347
362
|
if (this._compact === false) {
|
|
348
363
|
this._shadowContainer.setAttribute('open', '');
|
|
349
|
-
} else if (
|
|
364
|
+
} else if (
|
|
365
|
+
!this._shadowContainer.classList.contains('maplibregl-compact') &&
|
|
366
|
+
!this._shadowContainer.classList.contains('maplibregl-attrib-empty')
|
|
367
|
+
) {
|
|
350
368
|
this._shadowContainer.setAttribute('open', '');
|
|
351
|
-
this._shadowContainer.classList.add(
|
|
369
|
+
this._shadowContainer.classList.add(
|
|
370
|
+
'maplibregl-compact',
|
|
371
|
+
'maplibregl-compact-show',
|
|
372
|
+
);
|
|
352
373
|
}
|
|
353
374
|
} else {
|
|
354
375
|
this._shadowContainer.setAttribute('open', '');
|
|
355
376
|
if (this._shadowContainer.classList.contains('maplibregl-compact')) {
|
|
356
|
-
this._shadowContainer.classList.remove(
|
|
377
|
+
this._shadowContainer.classList.remove(
|
|
378
|
+
'maplibregl-compact',
|
|
379
|
+
'maplibregl-compact-show',
|
|
380
|
+
);
|
|
357
381
|
}
|
|
358
382
|
}
|
|
359
383
|
}
|
|
@@ -365,7 +389,6 @@ class CustomAttributionControl implements IControl {
|
|
|
365
389
|
}
|
|
366
390
|
}
|
|
367
391
|
}
|
|
368
|
-
|
|
369
392
|
}
|
|
370
393
|
|
|
371
394
|
export default CustomAttributionControl;
|