@geolonia/embed 5.2.2 → 6.0.0-pre.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 +25 -1
- package/CHANGELOG.md +9 -0
- package/README.md +24 -1
- package/dist/embed +1 -1
- package/dist/embed-chunks/4ada77b78cc0cc5ccef9.js +1 -0
- package/dist/embed-chunks/8176630945512b29f294.js +2 -0
- package/dist/embed-chunks/c783fffcd28083f7d5cb.js +2 -0
- package/dist/embed-chunks/f2124097fda51d0079ee.js +1 -0
- package/dist/embed-core.d.ts +6 -7
- package/dist/embed-core.js +1 -1
- package/dist/embed.d.ts +2 -4
- package/dist/embed.js +1 -1
- package/dist/lib/parse-atts.d.ts +19 -0
- package/dist/lib/render.d.ts +1 -1
- package/dist/lib/util.d.ts +14 -55
- package/dist/types.d.ts +155 -1
- package/dist/version.d.ts +1 -1
- package/e2e/auto-render.spec.ts +44 -0
- package/e2e/basic.spec.ts +10 -74
- package/e2e/cleanup.spec.ts +43 -0
- package/e2e/data-attributes.spec.ts +56 -0
- package/e2e/globals.spec.ts +51 -0
- package/e2e/helper.ts +170 -4
- package/e2e/iframe.spec.ts +35 -0
- package/e2e/lazy-loading.spec.ts +32 -0
- package/e2e/legacy-constructor.spec.ts +102 -0
- package/e2e/plugin.spec.ts +25 -0
- package/e2e/pmtiles.spec.ts +13 -0
- package/package.json +8 -11
- package/playwright.config.ts +6 -32
- package/src/embed-core.ts +12 -14
- package/src/embed.ts +2 -4
- package/src/lib/parse-atts.test.ts +186 -18
- package/src/lib/parse-atts.ts +151 -5
- package/src/lib/render.ts +50 -12
- package/src/lib/util.ts +37 -350
- package/src/types.ts +155 -1
- package/src/version.ts +1 -1
- package/typedoc.json +13 -0
- package/vitest.config.ts +7 -0
- package/dist/embed-chunks/12cbd0d1cb4cf744c32f.js +0 -2
- package/dist/embed-chunks/8a521e8312a5b4da123d.js +0 -2
- package/dist/lib/CustomAttributionControl.d.ts +0 -47
- package/dist/lib/controls/geolonia-control.d.ts +0 -7
- package/dist/lib/geolonia-map.d.ts +0 -30
- package/dist/lib/geolonia-marker.d.ts +0 -9
- package/dist/lib/keyring.d.ts +0 -45
- package/dist/lib/maplibre-util.d.ts +0 -25
- package/dist/lib/simplestyle-vector.d.ts +0 -26
- package/dist/lib/simplestyle.d.ts +0 -31
- package/e2e/external-style.spec.ts +0 -25
- package/e2e/map.spec.ts +0 -69
- package/src/lib/CustomAttributionControl.ts +0 -394
- package/src/lib/controls/geolonia-control.ts +0 -38
- package/src/lib/geolonia-map.ts +0 -429
- package/src/lib/geolonia-marker.ts +0 -53
- package/src/lib/keyring.test.ts +0 -127
- package/src/lib/keyring.ts +0 -136
- package/src/lib/maplibre-util.ts +0 -137
- package/src/lib/marker.svg +0 -1
- package/src/lib/simplestyle-vector.ts +0 -257
- package/src/lib/simplestyle.test.ts +0 -289
- package/src/lib/simplestyle.ts +0 -435
- package/src/lib/util.test.ts +0 -364
- /package/dist/embed-chunks/{12cbd0d1cb4cf744c32f.js.LICENSE.txt → 8176630945512b29f294.js.LICENSE.txt} +0 -0
- /package/dist/embed-chunks/{8a521e8312a5b4da123d.js.LICENSE.txt → c783fffcd28083f7d5cb.js.LICENSE.txt} +0 -0
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { ControlPosition, IControl } from 'maplibre-gl';
|
|
2
|
-
/**
|
|
3
|
-
* This class is a copy of maplibre-gl-js's AttributionControl class and rewrite by shadow DOM.
|
|
4
|
-
* https://github.com/maplibre/maplibre-gl-js/blob/main/src/ui/control/attribution_control.ts
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* When the map is too small to display the full attribution, it will be
|
|
8
|
-
* collapsed in to a "i" icon. It is open by default, and will hide itself
|
|
9
|
-
* when user interaction is detected.
|
|
10
|
-
* For more information on why this is open by default, see the following links:
|
|
11
|
-
*
|
|
12
|
-
* The OSM Foundation attribution guidelines.
|
|
13
|
-
* https://wiki.osmfoundation.org/wiki/Licence/Attribution_Guidelines#Interactive_maps
|
|
14
|
-
* > You may use a mechanism to fade/collapse the attribution under certain conditions:
|
|
15
|
-
* > * immediately with a dismiss interaction, for example clicking an ‘x’ in the corner of a dialog
|
|
16
|
-
* > * automatically on map interaction such as panning, clicking, or zooming
|
|
17
|
-
* > * automatically after five seconds. This also applies to splash screens or pop-ups.
|
|
18
|
-
*
|
|
19
|
-
* This is the issue where attribution is open by default in the MapLibre GL JS library:
|
|
20
|
-
* https://github.com/maplibre/maplibre-gl-js/issues/205
|
|
21
|
-
*/
|
|
22
|
-
declare class CustomAttributionControl implements IControl {
|
|
23
|
-
private options;
|
|
24
|
-
private _map;
|
|
25
|
-
private _compact;
|
|
26
|
-
private _container;
|
|
27
|
-
private _shadowContainer;
|
|
28
|
-
private _innerContainer;
|
|
29
|
-
private _compactButton;
|
|
30
|
-
private _editLink;
|
|
31
|
-
private _attribHTML;
|
|
32
|
-
private styleId;
|
|
33
|
-
private styleOwner;
|
|
34
|
-
private printQuery;
|
|
35
|
-
private onMediaPrintChange;
|
|
36
|
-
constructor(options?: {});
|
|
37
|
-
getDefaultPosition(): ControlPosition;
|
|
38
|
-
onAdd(map: any): any;
|
|
39
|
-
onRemove(): void;
|
|
40
|
-
_setElementTitle(element: any, title: any): void;
|
|
41
|
-
_toggleAttribution(): void;
|
|
42
|
-
_updateData(e: any): void;
|
|
43
|
-
_updateAttributions(): void;
|
|
44
|
-
_updateCompact(): void;
|
|
45
|
-
_updateCompactMinimize(): void;
|
|
46
|
-
}
|
|
47
|
-
export default CustomAttributionControl;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import maplibregl, { MapOptions, StyleOptions, StyleSpecification, StyleSwapOptions, GetResourceResponse } from 'maplibre-gl';
|
|
2
|
-
import { GetImageCallback } from './util';
|
|
3
|
-
export type GeoloniaMapOptions = MapOptions & {
|
|
4
|
-
interactive?: boolean;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Render the map
|
|
8
|
-
*
|
|
9
|
-
* @param container
|
|
10
|
-
*/
|
|
11
|
-
export default class GeoloniaMap extends maplibregl.Map {
|
|
12
|
-
private geoloniaSourcesUrl;
|
|
13
|
-
private __styleExtensionLoadRequired;
|
|
14
|
-
constructor(params: string | GeoloniaMapOptions);
|
|
15
|
-
/**
|
|
16
|
-
*
|
|
17
|
-
* @param {string|null} style style identity or `null` when map.remove()
|
|
18
|
-
* @param {*} options
|
|
19
|
-
*/
|
|
20
|
-
setStyle(style: string | StyleSpecification, options?: StyleSwapOptions & StyleOptions): this;
|
|
21
|
-
remove(): void;
|
|
22
|
-
/**
|
|
23
|
-
* Backward compatibility for breaking change of loadImage() in MapLibre GL JS v4.0.0.
|
|
24
|
-
* Related to https://github.com/maplibre/maplibre-gl-js/pull/3422/
|
|
25
|
-
* @param url
|
|
26
|
-
* @param callback
|
|
27
|
-
*/
|
|
28
|
-
loadImage(url: string, callback: GetImageCallback): void;
|
|
29
|
-
loadImage(url: string): Promise<GetResourceResponse<HTMLImageElement | ImageBitmap>>;
|
|
30
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import maplibregl, { type MarkerOptions } from 'maplibre-gl';
|
|
2
|
-
/**
|
|
3
|
-
* Geolonia default marker
|
|
4
|
-
*
|
|
5
|
-
* @param container
|
|
6
|
-
*/
|
|
7
|
-
export default class GeoloniaMarker extends maplibregl.Marker {
|
|
8
|
-
constructor(options?: MarkerOptions, legacyOptions?: MarkerOptions);
|
|
9
|
-
}
|
package/dist/lib/keyring.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
declare class Keyring {
|
|
2
|
-
#private;
|
|
3
|
-
/**
|
|
4
|
-
* @returns API key
|
|
5
|
-
*/
|
|
6
|
-
get apiKey(): string;
|
|
7
|
-
/**
|
|
8
|
-
* @returns Whether using Geolonia style (true) or external style (false)
|
|
9
|
-
*/
|
|
10
|
-
get isGeoloniaStyle(): boolean;
|
|
11
|
-
/**
|
|
12
|
-
* @param isGeoloniaStyle - Set whether using Geolonia style
|
|
13
|
-
*/
|
|
14
|
-
set isGeoloniaStyle(value: boolean);
|
|
15
|
-
/**
|
|
16
|
-
* @param key - API Key to set
|
|
17
|
-
*/
|
|
18
|
-
set apiKey(key: string);
|
|
19
|
-
/**
|
|
20
|
-
* @returns Stage name
|
|
21
|
-
*/
|
|
22
|
-
get stage(): string;
|
|
23
|
-
/**
|
|
24
|
-
* @param stage - Stage name to set
|
|
25
|
-
*/
|
|
26
|
-
set stage(stage: string);
|
|
27
|
-
/**
|
|
28
|
-
* Parses the API key and stage from the URL of the current script tag.
|
|
29
|
-
*
|
|
30
|
-
* @param {Document} document
|
|
31
|
-
*/
|
|
32
|
-
parse(doc?: Document): void;
|
|
33
|
-
/** Reset API key and stage for testing purpose */
|
|
34
|
-
reset(): void;
|
|
35
|
-
/**
|
|
36
|
-
* Check if the given style is a Geolonia style (requires API key)
|
|
37
|
-
* Note: This is a method, not the property. Use keyring.isGeoloniaStyle property
|
|
38
|
-
* to check the current style type, or call this method to check a specific style.
|
|
39
|
-
* @param style - Style name or URL
|
|
40
|
-
* @returns true if it's a Geolonia style (requires API key)
|
|
41
|
-
*/
|
|
42
|
-
isGeoloniaStyleCheck(style: string): boolean;
|
|
43
|
-
}
|
|
44
|
-
declare const keyring: Keyring;
|
|
45
|
-
export { keyring };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This class is a copy of maplibre-gl-js's util DOM class and rewrite it to JavaScript.
|
|
3
|
-
* https://github.com/maplibre/maplibre-gl-js/blob/main/src/util/dom.ts
|
|
4
|
-
* */
|
|
5
|
-
export declare class DOM {
|
|
6
|
-
#private;
|
|
7
|
-
static testProp(props: any): any;
|
|
8
|
-
static create(tagName: any, className?: any, container?: any): any;
|
|
9
|
-
static createNS(namespaceURI: any, tagName: any): HTMLElement;
|
|
10
|
-
static disableDrag(): void;
|
|
11
|
-
static enableDrag(): void;
|
|
12
|
-
static setTransform(el: any, value: any): void;
|
|
13
|
-
static addEventListener(target: any, type: any, callback: any, options: any): void;
|
|
14
|
-
static removeEventListener(target: any, type: any, callback: any, options: any): void;
|
|
15
|
-
static suppressClick(): void;
|
|
16
|
-
static mousePos(el: any, e: any): any;
|
|
17
|
-
static touchPos(el: any, touches: any): any[];
|
|
18
|
-
static mouseButton(e: any): any;
|
|
19
|
-
static remove(node: any): void;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* This function is a copy of maplibre-gl-js's util function and rewrite it to JavaScript.
|
|
23
|
-
* https://github.com/maplibre/maplibre-gl-js/blob/main/src/util/util.ts#L223-L228
|
|
24
|
-
* */
|
|
25
|
-
export declare function bindAll(fns: any, context: any): void;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
declare class SimpleStyleVector {
|
|
2
|
-
private url;
|
|
3
|
-
private sourceName;
|
|
4
|
-
constructor(url: any);
|
|
5
|
-
addTo(map: any): void;
|
|
6
|
-
/**
|
|
7
|
-
* Set polygon geometries.
|
|
8
|
-
*
|
|
9
|
-
* @param map
|
|
10
|
-
*/
|
|
11
|
-
setPolygonGeometries(map: any): void;
|
|
12
|
-
/**
|
|
13
|
-
* Set line geometries.
|
|
14
|
-
*
|
|
15
|
-
* @param map
|
|
16
|
-
*/
|
|
17
|
-
setLineGeometries(map: any): void;
|
|
18
|
-
/**
|
|
19
|
-
* Setup point geometries.
|
|
20
|
-
*
|
|
21
|
-
* @param map
|
|
22
|
-
*/
|
|
23
|
-
setPointGeometries(map: any): void;
|
|
24
|
-
setPopup(map: any, source: any): Promise<void>;
|
|
25
|
-
}
|
|
26
|
-
export default SimpleStyleVector;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export declare class SimpleStyle {
|
|
2
|
-
_loadingPromise: Promise<unknown>;
|
|
3
|
-
private callFitBounds;
|
|
4
|
-
private geojson;
|
|
5
|
-
private map;
|
|
6
|
-
private options;
|
|
7
|
-
private _eventHandlers;
|
|
8
|
-
constructor(geojson: any, options?: any);
|
|
9
|
-
updateData(geojson: any): this;
|
|
10
|
-
addTo(map: any): this;
|
|
11
|
-
fitBounds(options?: {}): this;
|
|
12
|
-
/**
|
|
13
|
-
* Set polygon geometries.
|
|
14
|
-
*/
|
|
15
|
-
setPolygonGeometries(): void;
|
|
16
|
-
/**
|
|
17
|
-
* Set line geometries.
|
|
18
|
-
*/
|
|
19
|
-
setLineGeometries(): void;
|
|
20
|
-
/**
|
|
21
|
-
* Setup point geometries.
|
|
22
|
-
*/
|
|
23
|
-
setPointGeometries(): void;
|
|
24
|
-
setPopup(map: any, source: any): Promise<void>;
|
|
25
|
-
/**
|
|
26
|
-
* Setup cluster markers
|
|
27
|
-
*/
|
|
28
|
-
setCluster(): void;
|
|
29
|
-
remove(): this;
|
|
30
|
-
setGeoJSON(geojson: any): void;
|
|
31
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { test, expect } from '@playwright/test';
|
|
2
|
-
import { TEST_URL, waitForMapLoad } from './helper';
|
|
3
|
-
|
|
4
|
-
const EXTERNAL_STYLE_URL = 'https://tile.openstreetmap.jp/styles/osm-bright/style.json';
|
|
5
|
-
|
|
6
|
-
test.describe('External Style Support', () => {
|
|
7
|
-
test('data-style で外部スタイルを指定しても地図が表示されること', async ({ page }) => {
|
|
8
|
-
await page.goto(`${TEST_URL}/external-style.html`);
|
|
9
|
-
await waitForMapLoad(page, '#map');
|
|
10
|
-
|
|
11
|
-
const mapCanvas = page.locator('#map canvas.maplibregl-canvas');
|
|
12
|
-
await expect(mapCanvas).toBeVisible();
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
test('data-style で指定した外部スタイルURLにアクセスしていること', async ({ page }) => {
|
|
16
|
-
const styleRequest = page.waitForRequest((req) =>
|
|
17
|
-
req.url().includes(EXTERNAL_STYLE_URL),
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
await page.goto(`${TEST_URL}/external-style.html`);
|
|
21
|
-
|
|
22
|
-
const req = await styleRequest;
|
|
23
|
-
expect(req.url()).toBe(EXTERNAL_STYLE_URL);
|
|
24
|
-
});
|
|
25
|
-
});
|
package/e2e/map.spec.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { test, expect } from '@playwright/test';
|
|
2
|
-
import { TEST_URL, LOAD_TIMEOUT, waitForMapLoad } from './helper';
|
|
3
|
-
|
|
4
|
-
test.describe('1. 基本的な地図表示', () => {
|
|
5
|
-
test.beforeEach(async ({ page }) => {
|
|
6
|
-
await page.goto(`${TEST_URL}/nocontrol.html`);
|
|
7
|
-
await waitForMapLoad(page);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
test.describe.serial('2.1 地図が表示できること', () => {
|
|
11
|
-
test('2.1.1 ページ読み込み時に地図がロードされること', async ({ page }) => {
|
|
12
|
-
// マップインスタンスが生成されていることを確認する。
|
|
13
|
-
// map.loaded()はすべてのタイルのレンダリング完了を意味するため、
|
|
14
|
-
// テスト用APIキーではタイル取得が失敗しタイムアウトする可能性がある。
|
|
15
|
-
// ここではインスタンス生成とキャンバス描画の確認のみ行う。
|
|
16
|
-
const hasMap = await page.evaluate(() => {
|
|
17
|
-
const container = document.querySelector('#map') as any;
|
|
18
|
-
return !!(container && container.geoloniaMap);
|
|
19
|
-
});
|
|
20
|
-
expect(hasMap).toBe(true);
|
|
21
|
-
|
|
22
|
-
const canvas = page.locator('.maplibregl-canvas');
|
|
23
|
-
await expect(canvas).toBeVisible();
|
|
24
|
-
});
|
|
25
|
-
test('2.1.2 タイルが描画されていることを確認(上半分のみ)', async ({ page }) => {
|
|
26
|
-
const isNotBlank = await page.evaluate(() => {
|
|
27
|
-
const canvas = document.querySelector('.maplibregl-canvas') as HTMLCanvasElement;
|
|
28
|
-
// WebGLコンテキストを取得
|
|
29
|
-
const gl = canvas.getContext('webgl2') || canvas.getContext('webgl');
|
|
30
|
-
|
|
31
|
-
if (!gl) {
|
|
32
|
-
return false; // WebGLコンテキストが取得できない場合
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const width = canvas.width;
|
|
36
|
-
const height = Math.floor(canvas.height / 2); // 上半分のみ
|
|
37
|
-
// ピクセルデータを読み取る
|
|
38
|
-
const pixels = new Uint8Array(width * height * 4);
|
|
39
|
-
|
|
40
|
-
// 下にAttributeがある場合、真っ白ではないため上半分だけを取得
|
|
41
|
-
// WebGLは下から上に向かって読み取るので、上半分を取得するには
|
|
42
|
-
// 下半分をスキップする必要がある
|
|
43
|
-
gl.readPixels(0, Math.floor(canvas.height / 2), width, height, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
|
|
44
|
-
// 色の分析
|
|
45
|
-
let nonWhiteCount = 0;
|
|
46
|
-
const totalPixels = pixels.length / 4;
|
|
47
|
-
|
|
48
|
-
for (let i = 0; i < pixels.length; i += 4) {
|
|
49
|
-
const r = pixels[i];
|
|
50
|
-
const g = pixels[i + 1];
|
|
51
|
-
const b = pixels[i + 2];
|
|
52
|
-
|
|
53
|
-
// 白以外のピクセルをカウント
|
|
54
|
-
if (r < 250 || g < 250 || b < 250) {
|
|
55
|
-
nonWhiteCount++;
|
|
56
|
-
|
|
57
|
-
// 早期終了:十分な非白色ピクセルが見つかったら
|
|
58
|
-
if (nonWhiteCount > totalPixels * 0.01) {
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return nonWhiteCount > 0;
|
|
65
|
-
});
|
|
66
|
-
expect(isNotBlank).toBe(true);
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
});
|