@geolonia/embed 6.0.1 → 6.1.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 +20 -0
- package/README.md +54 -6
- package/dist/embed +1 -1
- package/dist/embed-chunks/1b101382794d13cd280c.js +2 -0
- package/dist/embed-chunks/856a68e16ab05c382e6f.js +2 -0
- package/dist/embed-chunks/9a1056aa012055998dc3.js +1 -0
- package/dist/embed-chunks/{5f80e0235f4b38778d0d.js → bf6d08239720e38dacd6.js} +1 -1
- package/dist/embed-core.js +1 -1
- package/dist/embed.js +1 -1
- package/dist/types.d.ts +145 -7
- package/dist/version.d.ts +1 -1
- package/e2e/data-driven.spec.ts +9 -2
- package/e2e/mask.spec.ts +75 -0
- package/e2e/projection-raster-tiles.spec.ts +71 -0
- package/package.json +2 -2
- package/pnpm-workspace.yaml +6 -0
- package/src/lib/parse-atts.test.ts +531 -4
- package/src/lib/parse-atts.ts +261 -25
- package/src/types.ts +145 -7
- package/src/version.ts +1 -1
- package/dist/embed-chunks/9734b8bdf9fe84261b54.js +0 -2
- package/dist/embed-chunks/ae36f6b8e34f85ae3045.js +0 -2
- package/dist/embed-chunks/c83bb7c9a4a7ed9d5b23.js +0 -1
- /package/dist/embed-chunks/{9734b8bdf9fe84261b54.js.LICENSE.txt → 1b101382794d13cd280c.js.LICENSE.txt} +0 -0
- /package/dist/embed-chunks/{ae36f6b8e34f85ae3045.js.LICENSE.txt → 856a68e16ab05c382e6f.js.LICENSE.txt} +0 -0
package/src/lib/parse-atts.ts
CHANGED
|
@@ -7,8 +7,14 @@ import {
|
|
|
7
7
|
keyring,
|
|
8
8
|
type ChoroplethOptions,
|
|
9
9
|
type CircleOptions,
|
|
10
|
+
type ColorMap,
|
|
11
|
+
type ExtrusionColorOptions,
|
|
12
|
+
type ExtrusionHeightOptions,
|
|
13
|
+
type ExtrusionOptions,
|
|
10
14
|
type GeoloniaMapOptions,
|
|
11
15
|
type HeatmapOptions,
|
|
16
|
+
type MaskOptions,
|
|
17
|
+
type RasterTilesOptions,
|
|
12
18
|
} from '@geolonia/maps-core';
|
|
13
19
|
import type { EmbedAttributes } from '../types';
|
|
14
20
|
|
|
@@ -35,17 +41,6 @@ export default (
|
|
|
35
41
|
(container as unknown as { dataset: DOMStringMap }).dataset = {};
|
|
36
42
|
}
|
|
37
43
|
|
|
38
|
-
let lang: string;
|
|
39
|
-
if (container.dataset.lang && container.dataset.lang === 'auto') {
|
|
40
|
-
lang = getLang();
|
|
41
|
-
} else if (container.dataset.lang && container.dataset.lang === 'ja') {
|
|
42
|
-
lang = 'ja';
|
|
43
|
-
} else if (container.dataset.lang && container.dataset.lang !== 'ja') {
|
|
44
|
-
lang = 'en';
|
|
45
|
-
} else {
|
|
46
|
-
lang = getLang();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
44
|
// Check if using Geolonia style or external style
|
|
50
45
|
const style = container.dataset.style || 'geolonia/basic-v2';
|
|
51
46
|
keyring.isGeoloniaStyle = keyring.isGeoloniaStyleCheck(style);
|
|
@@ -73,7 +68,10 @@ export default (
|
|
|
73
68
|
cluster: 'on',
|
|
74
69
|
clusterColor: '#ff0000',
|
|
75
70
|
style: 'geolonia/basic-v2',
|
|
76
|
-
lang
|
|
71
|
+
// `data-lang` が指定されていれば、末尾の `...container.dataset` がその生の値で
|
|
72
|
+
// 上書きし、ja / en への解決は maps-core が行う。この値が残るのは
|
|
73
|
+
// `data-lang` が未指定のときだけ。
|
|
74
|
+
lang: getLang(),
|
|
77
75
|
plugin: 'off',
|
|
78
76
|
key: keyring.apiKey,
|
|
79
77
|
apiUrl: `https://api.geolonia.com/${keyring.stage}`,
|
|
@@ -122,8 +120,13 @@ const isCssSelector = (value: string): Element | false => {
|
|
|
122
120
|
|
|
123
121
|
/**
|
|
124
122
|
* Resolve a `data-geojson` value into what maps-core's SimpleStyle accepts:
|
|
125
|
-
* a URL
|
|
126
|
-
*
|
|
123
|
+
* a URL string, or the parsed content of the inline element a CSS selector
|
|
124
|
+
* points at. The content is not validated; it must be a FeatureCollection.
|
|
125
|
+
*
|
|
126
|
+
* Any other value is returned unchanged, and maps-core usually cannot draw it.
|
|
127
|
+
* Throws when the element's content is not valid JSON. See
|
|
128
|
+
* https://github.com/geolonia/embed/issues/570 for what happens with
|
|
129
|
+
* unsupported values.
|
|
127
130
|
*/
|
|
128
131
|
const resolveGeojson = (value: string): string | FeatureCollection => {
|
|
129
132
|
const el = isCssSelector(value);
|
|
@@ -134,25 +137,87 @@ const resolveGeojson = (value: string): string | FeatureCollection => {
|
|
|
134
137
|
};
|
|
135
138
|
|
|
136
139
|
/**
|
|
137
|
-
* Split a comma-separated list
|
|
138
|
-
*
|
|
140
|
+
* Split a comma-separated list. Commas inside parentheses (`rgb(0, 0, 0)`) are
|
|
141
|
+
* part of the item, not separators. Items are trimmed and empty ones dropped.
|
|
139
142
|
*/
|
|
140
|
-
const
|
|
141
|
-
const
|
|
143
|
+
const splitList = (value: string): string[] => {
|
|
144
|
+
const items: string[] = [];
|
|
142
145
|
let depth = 0;
|
|
143
146
|
let current = '';
|
|
144
147
|
for (const char of value) {
|
|
145
148
|
if (char === '(') depth++;
|
|
146
149
|
if (char === ')') depth = Math.max(0, depth - 1);
|
|
147
150
|
if (char === ',' && depth === 0) {
|
|
148
|
-
|
|
151
|
+
items.push(current);
|
|
149
152
|
current = '';
|
|
150
153
|
} else {
|
|
151
154
|
current += char;
|
|
152
155
|
}
|
|
153
156
|
}
|
|
154
|
-
|
|
155
|
-
return
|
|
157
|
+
items.push(current);
|
|
158
|
+
return items.map((c) => c.trim()).filter((c) => c !== '');
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
/** Split a comma-separated list of CSS colors (see {@link splitList}). */
|
|
162
|
+
const parseColors = (value: string): string[] => splitList(value);
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Index of the last `:` outside parentheses, or -1. CSS colors have no `:`
|
|
166
|
+
* outside parentheses, so the last one separates the value from the color and
|
|
167
|
+
* a value may itself contain `:` (`10:30:#ff0000`).
|
|
168
|
+
*/
|
|
169
|
+
const lastPairSeparator = (item: string): number => {
|
|
170
|
+
let depth = 0;
|
|
171
|
+
let index = -1;
|
|
172
|
+
for (let i = 0; i < item.length; i++) {
|
|
173
|
+
const char = item[i];
|
|
174
|
+
if (char === '(') depth++;
|
|
175
|
+
if (char === ')') depth = Math.max(0, depth - 1);
|
|
176
|
+
if (char === ':' && depth === 0) index = i;
|
|
177
|
+
}
|
|
178
|
+
return index;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Read a `-colors` attribute as either a list of colors or a value-to-color
|
|
183
|
+
* map (maps-core's `ColorMap`).
|
|
184
|
+
*
|
|
185
|
+
* - When no item has a `value:color` pair, it is a list of colors, as before.
|
|
186
|
+
* - When at least one item has a pair, it is a map. Items without a pair and
|
|
187
|
+
* pairs with an empty color are ignored with a `console.warn`. The value and
|
|
188
|
+
* the color are trimmed, so `: #fff` maps the empty value. A later pair for
|
|
189
|
+
* the same value wins.
|
|
190
|
+
*
|
|
191
|
+
* Returns `undefined` when nothing usable is left, so maps-core uses its
|
|
192
|
+
* default colors (an empty map would paint every feature in the fallback
|
|
193
|
+
* color instead).
|
|
194
|
+
*/
|
|
195
|
+
const parseColorsOrMap = (
|
|
196
|
+
value: string,
|
|
197
|
+
attribute: string,
|
|
198
|
+
): string[] | ColorMap | undefined => {
|
|
199
|
+
const items = splitList(value);
|
|
200
|
+
if (!items.some((item) => lastPairSeparator(item) !== -1)) {
|
|
201
|
+
return items.length > 0 ? items : undefined;
|
|
202
|
+
}
|
|
203
|
+
// On `{}`, assigning to `__proto__` goes to the prototype setter (which drops
|
|
204
|
+
// a string) instead of creating a key, so a `__proto__` value would be lost.
|
|
205
|
+
const map: ColorMap = Object.create(null) as ColorMap;
|
|
206
|
+
let size = 0;
|
|
207
|
+
for (const item of items) {
|
|
208
|
+
const index = lastPairSeparator(item);
|
|
209
|
+
const color = index === -1 ? '' : item.slice(index + 1).trim();
|
|
210
|
+
if (color === '') {
|
|
211
|
+
// eslint-disable-next-line no-console
|
|
212
|
+
console.warn(
|
|
213
|
+
`[Geolonia] ${attribute}: ignored "${item}", which is not a "value:color" pair with a color.`,
|
|
214
|
+
);
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
map[item.slice(0, index).trim()] = color;
|
|
218
|
+
size++;
|
|
219
|
+
}
|
|
220
|
+
return size > 0 ? map : undefined;
|
|
156
221
|
};
|
|
157
222
|
|
|
158
223
|
/**
|
|
@@ -184,8 +249,14 @@ const dataDrivenOptions = (
|
|
|
184
249
|
|
|
185
250
|
if (atts.choropleth) {
|
|
186
251
|
const choropleth: ChoroplethOptions = { property: String(atts.choropleth) };
|
|
187
|
-
|
|
188
|
-
|
|
252
|
+
const colors = atts.choroplethColors
|
|
253
|
+
? parseColorsOrMap(
|
|
254
|
+
String(atts.choroplethColors),
|
|
255
|
+
'data-choropleth-colors',
|
|
256
|
+
)
|
|
257
|
+
: undefined;
|
|
258
|
+
if (colors) {
|
|
259
|
+
choropleth.colors = colors;
|
|
189
260
|
}
|
|
190
261
|
const range = atts.choroplethRange
|
|
191
262
|
? parseRange(String(atts.choroplethRange))
|
|
@@ -217,8 +288,11 @@ const dataDrivenOptions = (
|
|
|
217
288
|
if (atts.circleColor) {
|
|
218
289
|
circle.color = String(atts.circleColor);
|
|
219
290
|
}
|
|
220
|
-
|
|
221
|
-
|
|
291
|
+
const colors = atts.circleColors
|
|
292
|
+
? parseColorsOrMap(String(atts.circleColors), 'data-circle-colors')
|
|
293
|
+
: undefined;
|
|
294
|
+
if (colors) {
|
|
295
|
+
circle.colors = colors;
|
|
222
296
|
}
|
|
223
297
|
options.circle = circle;
|
|
224
298
|
}
|
|
@@ -226,6 +300,150 @@ const dataDrivenOptions = (
|
|
|
226
300
|
return options;
|
|
227
301
|
};
|
|
228
302
|
|
|
303
|
+
/**
|
|
304
|
+
* Read a numeric attribute, or `undefined` when it is empty or not a finite
|
|
305
|
+
* number. `Number('')` is `0`, so empty strings are checked first.
|
|
306
|
+
*/
|
|
307
|
+
const finiteNumber = (value: unknown): number | undefined => {
|
|
308
|
+
if (value === undefined || String(value).trim() === '') {
|
|
309
|
+
return undefined;
|
|
310
|
+
}
|
|
311
|
+
const n = Number(value);
|
|
312
|
+
return Number.isFinite(n) ? n : undefined;
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Convert `data-raster-tiles` and its `-attribution` / `-opacity` / `-size` /
|
|
317
|
+
* `-min-zoom` / `-max-zoom` attributes into maps-core's `rasterTiles` option.
|
|
318
|
+
* The other attributes only apply when `data-raster-tiles` is present.
|
|
319
|
+
* Values maps-core would reject (a URL without `{z}`/`{x}`/`{y}`, an opacity
|
|
320
|
+
* outside 0 to 1) are passed through; maps-core warns about or clamps them.
|
|
321
|
+
*/
|
|
322
|
+
const rasterTilesOption = (
|
|
323
|
+
atts: EmbedAttributes,
|
|
324
|
+
): RasterTilesOptions | undefined => {
|
|
325
|
+
const url = String(atts.rasterTiles ?? '').trim();
|
|
326
|
+
if (!url) {
|
|
327
|
+
return undefined;
|
|
328
|
+
}
|
|
329
|
+
const rasterTiles: RasterTilesOptions = { url };
|
|
330
|
+
const attribution = String(atts.rasterTilesAttribution ?? '').trim();
|
|
331
|
+
if (attribution) {
|
|
332
|
+
rasterTiles.attribution = attribution;
|
|
333
|
+
}
|
|
334
|
+
const opacity = finiteNumber(atts.rasterTilesOpacity);
|
|
335
|
+
if (opacity !== undefined) {
|
|
336
|
+
rasterTiles.opacity = opacity;
|
|
337
|
+
}
|
|
338
|
+
const tileSize = finiteNumber(atts.rasterTilesSize);
|
|
339
|
+
if (tileSize !== undefined) {
|
|
340
|
+
rasterTiles.tileSize = tileSize;
|
|
341
|
+
}
|
|
342
|
+
const minZoom = finiteNumber(atts.rasterTilesMinZoom);
|
|
343
|
+
if (minZoom !== undefined) {
|
|
344
|
+
rasterTiles.minZoom = minZoom;
|
|
345
|
+
}
|
|
346
|
+
const maxZoom = finiteNumber(atts.rasterTilesMaxZoom);
|
|
347
|
+
if (maxZoom !== undefined) {
|
|
348
|
+
rasterTiles.maxZoom = maxZoom;
|
|
349
|
+
}
|
|
350
|
+
return rasterTiles;
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
/** Read a string attribute trimmed, or `undefined` when it is empty. */
|
|
354
|
+
const trimmed = (value: unknown): string | undefined => {
|
|
355
|
+
const text = String(value ?? '').trim();
|
|
356
|
+
return text === '' ? undefined : text;
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Convert `data-extrusion` and its `-max-height` / `-height-scale` /
|
|
361
|
+
* `-height-range` / `-color` / `-colors` / `-color-range` attributes into
|
|
362
|
+
* maps-core's `extrusion` option. The other attributes only apply when
|
|
363
|
+
* `data-extrusion` is present. Values that cannot be read (not a finite number,
|
|
364
|
+
* not a `min,max` range) are left out so maps-core uses its defaults.
|
|
365
|
+
*/
|
|
366
|
+
const extrusionOption = (
|
|
367
|
+
atts: EmbedAttributes,
|
|
368
|
+
): string | ExtrusionOptions | undefined => {
|
|
369
|
+
const property = trimmed(atts.extrusion);
|
|
370
|
+
if (!property) {
|
|
371
|
+
return undefined;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const height: ExtrusionHeightOptions = { property };
|
|
375
|
+
const maxHeight = finiteNumber(atts.extrusionMaxHeight);
|
|
376
|
+
if (maxHeight !== undefined) {
|
|
377
|
+
height.maxHeight = maxHeight;
|
|
378
|
+
}
|
|
379
|
+
const heightScale = finiteNumber(atts.extrusionHeightScale);
|
|
380
|
+
if (heightScale !== undefined) {
|
|
381
|
+
height.heightScale = heightScale;
|
|
382
|
+
}
|
|
383
|
+
const heightRange = atts.extrusionHeightRange
|
|
384
|
+
? parseRange(String(atts.extrusionHeightRange))
|
|
385
|
+
: undefined;
|
|
386
|
+
if (heightRange) {
|
|
387
|
+
height.range = heightRange;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// 色のプロパティを省略すると、maps-core は高さと同じプロパティで色分けする。
|
|
391
|
+
const color: ExtrusionColorOptions = {
|
|
392
|
+
property: trimmed(atts.extrusionColor) ?? property,
|
|
393
|
+
};
|
|
394
|
+
const colors = atts.extrusionColors
|
|
395
|
+
? parseColorsOrMap(String(atts.extrusionColors), 'data-extrusion-colors')
|
|
396
|
+
: undefined;
|
|
397
|
+
if (colors) {
|
|
398
|
+
color.colors = colors;
|
|
399
|
+
}
|
|
400
|
+
const colorRange = atts.extrusionColorRange
|
|
401
|
+
? parseRange(String(atts.extrusionColorRange))
|
|
402
|
+
: undefined;
|
|
403
|
+
if (colorRange) {
|
|
404
|
+
color.range = colorRange;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
if (Object.keys(height).length === 1 && Object.keys(color).length === 1) {
|
|
408
|
+
return color.property === property
|
|
409
|
+
? property
|
|
410
|
+
: { height: property, color: color.property };
|
|
411
|
+
}
|
|
412
|
+
return { height, color };
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Convert `data-mask` and its `-color` / `-opacity` / `-outline` attributes
|
|
417
|
+
* into maps-core's `mask` option. The other attributes only apply when
|
|
418
|
+
* `data-mask` is present. `data-mask` is passed as is (trimmed); maps-core
|
|
419
|
+
* reports a value that is not a URL with `console.error` and adds no mask.
|
|
420
|
+
*/
|
|
421
|
+
const maskOption = (
|
|
422
|
+
atts: EmbedAttributes,
|
|
423
|
+
): string | MaskOptions | undefined => {
|
|
424
|
+
const geojson = trimmed(atts.mask);
|
|
425
|
+
if (!geojson) {
|
|
426
|
+
return undefined;
|
|
427
|
+
}
|
|
428
|
+
const mask: MaskOptions = { geojson };
|
|
429
|
+
const color = trimmed(atts.maskColor);
|
|
430
|
+
if (color) {
|
|
431
|
+
mask.color = color;
|
|
432
|
+
}
|
|
433
|
+
const opacity = finiteNumber(atts.maskOpacity);
|
|
434
|
+
if (opacity !== undefined) {
|
|
435
|
+
mask.opacity = opacity;
|
|
436
|
+
}
|
|
437
|
+
if (
|
|
438
|
+
String(atts.maskOutline ?? '')
|
|
439
|
+
.trim()
|
|
440
|
+
.toLowerCase() === 'on'
|
|
441
|
+
) {
|
|
442
|
+
mask.outline = true;
|
|
443
|
+
}
|
|
444
|
+
return Object.keys(mask).length === 1 ? geojson : mask;
|
|
445
|
+
};
|
|
446
|
+
|
|
229
447
|
/**
|
|
230
448
|
* Convert normalised {@link EmbedAttributes} into a typed `GeoloniaMapOptions`
|
|
231
449
|
* for maps-core's `GeoloniaMap` constructor.
|
|
@@ -298,6 +516,24 @@ export const attsToOptions = (
|
|
|
298
516
|
}
|
|
299
517
|
Object.assign(options, dataDrivenOptions(atts));
|
|
300
518
|
|
|
519
|
+
// `globe` / `mercator` 以外の値は maps-core が console.error に出して無視する。
|
|
520
|
+
const projection = String(atts.projection ?? '').trim();
|
|
521
|
+
if (projection) {
|
|
522
|
+
options.projection = projection as GeoloniaMapOptions['projection'];
|
|
523
|
+
}
|
|
524
|
+
const rasterTiles = rasterTilesOption(atts);
|
|
525
|
+
if (rasterTiles) {
|
|
526
|
+
options.rasterTiles = rasterTiles;
|
|
527
|
+
}
|
|
528
|
+
const extrusion = extrusionOption(atts);
|
|
529
|
+
if (extrusion) {
|
|
530
|
+
options.extrusion = extrusion;
|
|
531
|
+
}
|
|
532
|
+
const mask = maskOption(atts);
|
|
533
|
+
if (mask) {
|
|
534
|
+
options.mask = mask;
|
|
535
|
+
}
|
|
536
|
+
|
|
301
537
|
if (
|
|
302
538
|
atts.minZoom !== '' &&
|
|
303
539
|
(Number(atts.minZoom) === 0 || Number(atts.minZoom))
|
package/src/types.ts
CHANGED
|
@@ -105,9 +105,14 @@ export type EmbedAttributes = {
|
|
|
105
105
|
*/
|
|
106
106
|
geoloniaControl: string;
|
|
107
107
|
/**
|
|
108
|
-
* `data-geojson`:GeoJSON のソース。URL
|
|
109
|
-
*
|
|
110
|
-
*
|
|
108
|
+
* `data-geojson`:GeoJSON のソース。URL(`https://...`、`/data.geojson`、
|
|
109
|
+
* `./data.geojson`、`../data.geojson` など)か、地図コンテナの外に置いた、中身が
|
|
110
|
+
* GeoJSON の FeatureCollection の要素(`<script type="application/json">` など)を
|
|
111
|
+
* 指す CSS セレクタのいずれか。
|
|
112
|
+
*
|
|
113
|
+
* これ以外の値(インラインの JSON 文字列、`./` を付けない相対パス、何も指さない
|
|
114
|
+
* セレクタなど)は扱えず、地物は描かれない(多くの場合はエラーになる)。対応外の
|
|
115
|
+
* 値で起きることの詳細は https://github.com/geolonia/embed/issues/570 を参照。
|
|
111
116
|
* @defaultValue `''`
|
|
112
117
|
*/
|
|
113
118
|
geojson: string;
|
|
@@ -128,10 +133,13 @@ export type EmbedAttributes = {
|
|
|
128
133
|
*/
|
|
129
134
|
style: string;
|
|
130
135
|
/**
|
|
131
|
-
* `data-lang
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
136
|
+
* `data-lang`:ラベルとジェスチャー制御の文言の言語。指定した値はそのまま
|
|
137
|
+
* maps-core に渡る。`'ja'` と `'ja-jp'` は日本語、`'auto'` と空文字はブラウザ
|
|
138
|
+
* 言語に従い、それ以外の値は英語になる。比較は大文字と小文字を区別するので、
|
|
139
|
+
* `'ja-JP'` は英語になる。ラベルに効くのは、`data-style` を省略したときか
|
|
140
|
+
* Geolonia のスタイル名を指定したときだけ。`'ja'`、`'en'`、`'auto'`、空文字以外の
|
|
141
|
+
* 値では、`'ja-jp'` も含めてジェスチャー制御が付かない
|
|
142
|
+
* (https://github.com/geolonia/embed/issues/571)。
|
|
135
143
|
* @defaultValue 未指定のときは `getLang()` の結果(`'ja'` または `'en'`)
|
|
136
144
|
*/
|
|
137
145
|
lang: string;
|
|
@@ -178,6 +186,8 @@ export type EmbedAttributes = {
|
|
|
178
186
|
choropleth?: string;
|
|
179
187
|
/**
|
|
180
188
|
* `data-choropleth-colors`:塗り分けの色。値の小さい側から順にカンマで区切る。
|
|
189
|
+
* `値:色` の組をカンマで区切ると、値ごとの色の対応表になる(`data-choropleth-range`
|
|
190
|
+
* は使わない)。組の読み方は `data-circle-colors` と同じ。
|
|
181
191
|
* `data-choropleth` が無いときは無視する。
|
|
182
192
|
*/
|
|
183
193
|
choroplethColors?: string;
|
|
@@ -193,6 +203,7 @@ export type EmbedAttributes = {
|
|
|
193
203
|
heatmap?: string;
|
|
194
204
|
/**
|
|
195
205
|
* `data-heatmap-colors`:ヒートマップの色。密度の低い側から順にカンマで区切る。
|
|
206
|
+
* 密度に対する色なので、`値:色` の組(対応表)には対応しない。
|
|
196
207
|
* `data-heatmap` が無いときは無視する。
|
|
197
208
|
*/
|
|
198
209
|
heatmapColors?: string;
|
|
@@ -202,9 +213,136 @@ export type EmbedAttributes = {
|
|
|
202
213
|
circleColor?: string;
|
|
203
214
|
/**
|
|
204
215
|
* `data-circle-colors`:`data-circle-color` に使う色をカンマで区切る。
|
|
216
|
+
* `normal:#3b82f6, danger:#ef4444` のように `値:色` の組をカンマで区切ると、
|
|
217
|
+
* 値ごとの色の対応表になる。組の読み方は次のとおり。
|
|
218
|
+
*
|
|
219
|
+
* - 組が 1 つでもあれば対応表として読む。`:` の無い項目と色が空の組は、
|
|
220
|
+
* コンソールに警告を出して無視する。
|
|
221
|
+
* - 値と色は、括弧の外にある最後の `:` で分ける。値に `:` を含めてよい。
|
|
222
|
+
* - 項目は括弧の外のカンマで区切る。括弧の中のカンマ(`rgb(0, 0, 0)`)は
|
|
223
|
+
* 区切りとして扱わないので、括弧は閉じて書く。閉じていない `(` があると、
|
|
224
|
+
* それより後ろのカンマと `:` を区切りとして読まない。
|
|
225
|
+
* - 値と色の前後の空白は除く。同じ値の組が複数あれば後のものを使う。
|
|
226
|
+
* - 使える組が 1 つも無ければ、指定しなかったときと同じ既定の色になる。
|
|
227
|
+
* - 対応表にない値の地物の色は、maps-core の `ColorMap` の規則に従う。
|
|
228
|
+
*
|
|
205
229
|
* `data-circle-size` と `data-circle-color` のどちらも無いときは無視する。
|
|
206
230
|
*/
|
|
207
231
|
circleColors?: string;
|
|
232
|
+
/**
|
|
233
|
+
* `data-extrusion`:`data-geojson` のポリゴンを、このプロパティの値に応じた高さで
|
|
234
|
+
* 立体的に描く。色も、`data-extrusion-color` を省略すると同じプロパティで決める。
|
|
235
|
+
* 地物の simplestyle の `fill` と `data-choropleth` より優先する。立体に見せるには
|
|
236
|
+
* `data-pitch` も指定する。`data-geojson` が無いときは何も描かない。
|
|
237
|
+
*/
|
|
238
|
+
extrusion?: string;
|
|
239
|
+
/**
|
|
240
|
+
* `data-extrusion-max-height`:`data-extrusion-height-range` の最大値に割り当てる
|
|
241
|
+
* 高さ(メートル)。`data-extrusion-height-scale` があるときは使わない。数値として
|
|
242
|
+
* 読めないときは無視する。`data-extrusion` が無いときは無視する。
|
|
243
|
+
*/
|
|
244
|
+
extrusionMaxHeight?: string;
|
|
245
|
+
/**
|
|
246
|
+
* `data-extrusion-height-scale`:値 1 あたりの高さ(メートル)。指定すると高さは
|
|
247
|
+
* 「値 × この数」になる。数値として読めないときは無視する。`data-extrusion` が
|
|
248
|
+
* 無いときは無視する。
|
|
249
|
+
*/
|
|
250
|
+
extrusionHeightScale?: string;
|
|
251
|
+
/**
|
|
252
|
+
* `data-extrusion-height-range`:高さ 0 から最大の高さに割り当てる値の範囲。
|
|
253
|
+
* `"最小,最大"` 形式。省略時や読めないときはデータの値から決める。
|
|
254
|
+
* `data-extrusion` が無いときは無視する。
|
|
255
|
+
*/
|
|
256
|
+
extrusionHeightRange?: string;
|
|
257
|
+
/**
|
|
258
|
+
* `data-extrusion-color`:色に使うプロパティ名。省略すると `data-extrusion` と同じ
|
|
259
|
+
* プロパティで色分けする。`data-extrusion` が無いときは無視する。
|
|
260
|
+
*/
|
|
261
|
+
extrusionColor?: string;
|
|
262
|
+
/**
|
|
263
|
+
* `data-extrusion-colors`:色。数値は値の小さい側から順に、カテゴリは出現順に
|
|
264
|
+
* 割り当てる色をカンマで区切る。`値:色` の組をカンマで区切ると、値ごとの色の
|
|
265
|
+
* 対応表になる(`data-extrusion-color-range` は使わない)。組の読み方は
|
|
266
|
+
* `data-circle-colors` と同じ。`data-extrusion` が無いときは無視する。
|
|
267
|
+
*/
|
|
268
|
+
extrusionColors?: string;
|
|
269
|
+
/**
|
|
270
|
+
* `data-extrusion-color-range`:数値の色を割り当てる値の範囲。`"最小,最大"` 形式。
|
|
271
|
+
* 省略時や読めないときはデータの最小値と最大値を使う。`data-extrusion` が無い
|
|
272
|
+
* ときは無視する。
|
|
273
|
+
*/
|
|
274
|
+
extrusionColorRange?: string;
|
|
275
|
+
/**
|
|
276
|
+
* `data-mask`:指定した範囲の外側を暗くする。境界の GeoJSON の URL(`http://` か
|
|
277
|
+
* `https://` で始まるもの、または `/` か `.` で始まるパス)を指定する。それ以外の
|
|
278
|
+
* 値は maps-core がコンソールにエラーを出して無視する。中心(`data-lat` と
|
|
279
|
+
* `data-lng` の両方)、`data-geojson`、`data-simple-vector` のどれも指定して
|
|
280
|
+
* いないときは、境界の範囲に合わせて表示する。
|
|
281
|
+
*/
|
|
282
|
+
mask?: string;
|
|
283
|
+
/**
|
|
284
|
+
* `data-mask-color`:範囲の外側を塗る色。省略すると maps-core の既定値(黒)。
|
|
285
|
+
* `data-mask` が無いときは無視する。
|
|
286
|
+
*/
|
|
287
|
+
maskColor?: string;
|
|
288
|
+
/**
|
|
289
|
+
* `data-mask-opacity`:範囲の外側を塗る不透明度(0 から 1)。数値として読めない
|
|
290
|
+
* ときは無視する。0 から 1 の外の値は maps-core がコンソールにエラーを出して
|
|
291
|
+
* 既定値(0.3)を使う。`data-mask` が無いときは無視する。
|
|
292
|
+
*/
|
|
293
|
+
maskOpacity?: string;
|
|
294
|
+
/**
|
|
295
|
+
* `data-mask-outline`(`'on'` / `'off'`):境界に線を引く。線は `data-mask-color`
|
|
296
|
+
* の色で太さ 2 ピクセル。`data-mask` が無いときは無視する。
|
|
297
|
+
* @defaultValue 未指定のときは引かない
|
|
298
|
+
*/
|
|
299
|
+
maskOutline?: string;
|
|
300
|
+
/**
|
|
301
|
+
* `data-projection`:地図の投影。`'globe'` で地球儀、`'mercator'` で平面に
|
|
302
|
+
* する。値は前後の空白を除いて maps-core に渡り、それ以外の値は maps-core が
|
|
303
|
+
* コンソールにエラーを出して無視する。省略したときと空のときは、スタイルの投影(無ければ
|
|
304
|
+
* mercator)のまま。
|
|
305
|
+
*/
|
|
306
|
+
projection?: string;
|
|
307
|
+
/**
|
|
308
|
+
* `data-raster-tiles`:重ねるラスタタイルの URL のテンプレート。`{z}`、`{x}`、
|
|
309
|
+
* `{y}` を含める。スタイルの最初の symbol レイヤ(ラベル)の下に 1 枚重ね、
|
|
310
|
+
* symbol レイヤが無いスタイルではスタイルのレイヤの一番上に重ねる。どちらの
|
|
311
|
+
* 場合も `data-geojson` と `data-simple-vector` のレイヤはその上に描く。含まない
|
|
312
|
+
* ときは maps-core がコンソールに警告を出して重ねない。
|
|
313
|
+
*/
|
|
314
|
+
rasterTiles?: string;
|
|
315
|
+
/**
|
|
316
|
+
* `data-raster-tiles-attribution`:重ねたタイルの出典。地図の出典表示に加わる。
|
|
317
|
+
* HTML として表示するので、ページの作者が書いた値だけを入れ、URL のパラメータ
|
|
318
|
+
* など外から受け取った値を入れない。空のときと、`data-raster-tiles` が無いときは
|
|
319
|
+
* 無視する。
|
|
320
|
+
*/
|
|
321
|
+
rasterTilesAttribution?: string;
|
|
322
|
+
/**
|
|
323
|
+
* `data-raster-tiles-opacity`:重ねたタイルの不透明度(0 から 1)。範囲を超える
|
|
324
|
+
* 値は maps-core が範囲内に収める。数値として読めないときは無視する(maps-core
|
|
325
|
+
* の既定値 1 になる)。`data-raster-tiles` が無いときは無視する。
|
|
326
|
+
*/
|
|
327
|
+
rasterTilesOpacity?: string;
|
|
328
|
+
/**
|
|
329
|
+
* `data-raster-tiles-size`:タイル 1 枚の大きさ(ピクセル)。数値として読めない
|
|
330
|
+
* ときは無視する(maps-core の既定値 256 になる)。`data-raster-tiles` が無い
|
|
331
|
+
* ときは無視する。
|
|
332
|
+
*/
|
|
333
|
+
rasterTilesSize?: string;
|
|
334
|
+
/**
|
|
335
|
+
* `data-raster-tiles-min-zoom`:タイルが配信されている最小ズーム。これより
|
|
336
|
+
* 小さいズームではタイルを読み込まない。数値として読めないときは無視する。
|
|
337
|
+
* `data-raster-tiles` が無いときは無視する。
|
|
338
|
+
*/
|
|
339
|
+
rasterTilesMinZoom?: string;
|
|
340
|
+
/**
|
|
341
|
+
* `data-raster-tiles-max-zoom`:タイルが配信されている最大ズーム。これより
|
|
342
|
+
* 大きいズームでは、このズームのタイルを引き伸ばして表示する。数値として
|
|
343
|
+
* 読めないときは無視する。`data-raster-tiles` が無いときは無視する。
|
|
344
|
+
*/
|
|
345
|
+
rasterTilesMaxZoom?: string;
|
|
208
346
|
/**
|
|
209
347
|
* 追加の `data-*` 属性はそのまま透過される({@link EmbedPlugin} が利用する
|
|
210
348
|
* プラグイン固有の属性など)。
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '6.0
|
|
1
|
+
export const VERSION = '6.1.0';
|