@maplat/ui 0.11.11 → 0.12.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/README.ja.md +4 -0
- package/README.md +4 -0
- package/dist/{browser-ponyfill-qRQXCn5V.js → browser-ponyfill-BdqWNzYY.js} +1 -1
- package/dist/browserlanguage.d.ts +2 -0
- package/dist/{index-dwjwxaby.js → index-CqW0y3m3.js} +4593 -4469
- package/dist/index.d.ts +1 -0
- package/dist/maplat_ui.es.js +1 -1
- package/dist/maplat_ui.umd.js +231 -231
- package/dist/service-worker.js +1 -1
- package/dist/types.d.ts +195 -185
- package/dist/ui_utils.d.ts +13 -13
- package/package.json +2 -2
- package/src/browserlanguage.ts +35 -0
- package/src/index.ts +19 -11
- package/src/maplat_control.ts +630 -630
- package/src/types.ts +213 -202
- package/src/ui_init.ts +441 -267
- package/src/ui_marker.ts +409 -409
- package/src/ui_utils.ts +134 -134
package/dist/service-worker.js
CHANGED
|
@@ -3335,7 +3335,7 @@ This is generally NOT safe. Learn more at https://bit.ly/wb-precache`;
|
|
|
3335
3335
|
registerRoute(
|
|
3336
3336
|
/(?:maps\/.+\.json|pwa\/.+|pois\/.+\.json|apps\/.+\.json|tmbs\/.+\.jpg|images\/.+\.(?:png|jpg))$/,
|
|
3337
3337
|
new StaleWhileRevalidate({
|
|
3338
|
-
cacheName: `resourcesCache-${"2026-01-
|
|
3338
|
+
cacheName: `resourcesCache-${"2026-01-12-04-59"}`,
|
|
3339
3339
|
plugins: [
|
|
3340
3340
|
new ExpirationPlugin({
|
|
3341
3341
|
maxAgeSeconds: 86400,
|
package/dist/types.d.ts
CHANGED
|
@@ -1,185 +1,195 @@
|
|
|
1
|
-
import { Swiper as SwiperClass } from 'swiper';
|
|
2
|
-
import { Control } from 'ol/control';
|
|
3
|
-
import { MaplatUi } from './index';
|
|
4
|
-
export interface MaplatAppOption {
|
|
5
|
-
appid?: string;
|
|
6
|
-
fake?: boolean;
|
|
7
|
-
pwaManifest?: boolean | string;
|
|
8
|
-
pwaWorker?: string;
|
|
9
|
-
pwaScope?: string;
|
|
10
|
-
overlay?: boolean;
|
|
11
|
-
enableHideMarker?: boolean;
|
|
12
|
-
enableMarkerList?: boolean;
|
|
13
|
-
enableBorder?: boolean;
|
|
14
|
-
enableCache?: boolean;
|
|
15
|
-
stateUrl?: boolean;
|
|
16
|
-
enableShare?: boolean;
|
|
17
|
-
enablePoiHtmlNoScroll?: boolean;
|
|
18
|
-
disableNoimage?: boolean;
|
|
19
|
-
alwaysGpsOn?: boolean;
|
|
20
|
-
mobileIF?: boolean;
|
|
21
|
-
debug?: boolean;
|
|
22
|
-
appEnvelope?: boolean;
|
|
23
|
-
mapboxToken?: string;
|
|
24
|
-
googleApiKey?: string;
|
|
25
|
-
lang?: string;
|
|
26
|
-
restore?: RestoreState;
|
|
27
|
-
restoreSession?: boolean;
|
|
28
|
-
presentationMode?: boolean;
|
|
29
|
-
northTop?: boolean;
|
|
30
|
-
mapboxgl?: unknown;
|
|
31
|
-
maplibregl?: unknown;
|
|
32
|
-
markerList?: boolean;
|
|
33
|
-
icon?: string;
|
|
34
|
-
translateUI?: boolean;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
export interface
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
1
|
+
import { Swiper as SwiperClass } from 'swiper';
|
|
2
|
+
import { Control } from 'ol/control';
|
|
3
|
+
import { MaplatUi } from './index';
|
|
4
|
+
export interface MaplatAppOption {
|
|
5
|
+
appid?: string;
|
|
6
|
+
fake?: boolean;
|
|
7
|
+
pwaManifest?: boolean | string;
|
|
8
|
+
pwaWorker?: string;
|
|
9
|
+
pwaScope?: string;
|
|
10
|
+
overlay?: boolean;
|
|
11
|
+
enableHideMarker?: boolean;
|
|
12
|
+
enableMarkerList?: boolean;
|
|
13
|
+
enableBorder?: boolean;
|
|
14
|
+
enableCache?: boolean;
|
|
15
|
+
stateUrl?: boolean;
|
|
16
|
+
enableShare?: boolean;
|
|
17
|
+
enablePoiHtmlNoScroll?: boolean;
|
|
18
|
+
disableNoimage?: boolean;
|
|
19
|
+
alwaysGpsOn?: boolean;
|
|
20
|
+
mobileIF?: boolean;
|
|
21
|
+
debug?: boolean;
|
|
22
|
+
appEnvelope?: boolean;
|
|
23
|
+
mapboxToken?: string;
|
|
24
|
+
googleApiKey?: string;
|
|
25
|
+
lang?: string;
|
|
26
|
+
restore?: RestoreState;
|
|
27
|
+
restoreSession?: boolean;
|
|
28
|
+
presentationMode?: boolean;
|
|
29
|
+
northTop?: boolean;
|
|
30
|
+
mapboxgl?: unknown;
|
|
31
|
+
maplibregl?: unknown;
|
|
32
|
+
markerList?: boolean;
|
|
33
|
+
icon?: string;
|
|
34
|
+
translateUI?: boolean;
|
|
35
|
+
uiHooks?: MaplatUiHooks;
|
|
36
|
+
}
|
|
37
|
+
export interface MaplatUiHooks {
|
|
38
|
+
onSettingLoaded?: (context: unknown) => Promise<unknown> | unknown;
|
|
39
|
+
onAppdataReady?: (context: unknown) => Promise<unknown> | unknown;
|
|
40
|
+
onUiConfigure?: (context: unknown) => Promise<unknown> | unknown;
|
|
41
|
+
onCoreDomReady?: (context: unknown) => Promise<unknown> | unknown;
|
|
42
|
+
onUiDomReady?: (context: unknown) => Promise<unknown> | unknown;
|
|
43
|
+
onCoreReady?: (context: unknown) => Promise<unknown> | unknown;
|
|
44
|
+
onUiReady?: (context: unknown) => Promise<unknown> | unknown;
|
|
45
|
+
}
|
|
46
|
+
export interface RestoreState {
|
|
47
|
+
mapID?: string;
|
|
48
|
+
backgroundID?: string;
|
|
49
|
+
transparency?: number;
|
|
50
|
+
position?: {
|
|
51
|
+
rotation?: number;
|
|
52
|
+
zoom?: number;
|
|
53
|
+
x?: number;
|
|
54
|
+
y?: number;
|
|
55
|
+
};
|
|
56
|
+
showBorder?: boolean;
|
|
57
|
+
hideMarker?: boolean;
|
|
58
|
+
hideLayer?: string;
|
|
59
|
+
openedMarker?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface MapSource {
|
|
62
|
+
mapID: string;
|
|
63
|
+
title?: string;
|
|
64
|
+
officialTitle?: string;
|
|
65
|
+
label?: string;
|
|
66
|
+
width?: number;
|
|
67
|
+
height?: number;
|
|
68
|
+
envelope?: {
|
|
69
|
+
geometry: {
|
|
70
|
+
coordinates: number[][][];
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
envelopeColor?: string;
|
|
74
|
+
envelopeAreaIndex?: number;
|
|
75
|
+
xy2SysCoord?: (xy: number[]) => Promise<number[]> | number[];
|
|
76
|
+
thumbnail?: string;
|
|
77
|
+
}
|
|
78
|
+
export type MediaObject = {
|
|
79
|
+
src: string;
|
|
80
|
+
thumbnail?: string;
|
|
81
|
+
type?: string;
|
|
82
|
+
caption?: string;
|
|
83
|
+
desc?: string;
|
|
84
|
+
"fit-to-container"?: boolean;
|
|
85
|
+
"debug-mode"?: boolean;
|
|
86
|
+
"camera-position"?: string;
|
|
87
|
+
"camera-target"?: string;
|
|
88
|
+
"show-texture"?: boolean;
|
|
89
|
+
[key: string]: unknown;
|
|
90
|
+
};
|
|
91
|
+
export type MediaSetting = string | MediaObject;
|
|
92
|
+
export interface MarkerData {
|
|
93
|
+
markerId: string;
|
|
94
|
+
lnglat?: number[];
|
|
95
|
+
title?: string;
|
|
96
|
+
icon?: string;
|
|
97
|
+
description?: string;
|
|
98
|
+
images?: string[];
|
|
99
|
+
image?: MediaSetting | MediaSetting[];
|
|
100
|
+
media?: MediaSetting | MediaSetting[];
|
|
101
|
+
address?: string;
|
|
102
|
+
desc?: string;
|
|
103
|
+
url?: string;
|
|
104
|
+
html?: string;
|
|
105
|
+
directgo?: string | {
|
|
106
|
+
href: string;
|
|
107
|
+
blank?: boolean;
|
|
108
|
+
};
|
|
109
|
+
namespaceID?: string;
|
|
110
|
+
name?: string;
|
|
111
|
+
}
|
|
112
|
+
export interface ClickMarkersEvent {
|
|
113
|
+
pixel: number[];
|
|
114
|
+
coord: number[];
|
|
115
|
+
list: MarkerData[];
|
|
116
|
+
}
|
|
117
|
+
export interface ContextMenuInterface {
|
|
118
|
+
clear: () => void;
|
|
119
|
+
extend: (items: unknown[]) => void;
|
|
120
|
+
on: (event: string, handler: (e: unknown) => void) => void;
|
|
121
|
+
un: (event: string, handler: (e: unknown) => void) => void;
|
|
122
|
+
Internal?: {
|
|
123
|
+
openMenu: (pixel: number[], coord: number[]) => void;
|
|
124
|
+
closeMenu: () => void;
|
|
125
|
+
opened: boolean;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
export interface ClickMarkersEvent {
|
|
129
|
+
pixel: number[];
|
|
130
|
+
coord: number[];
|
|
131
|
+
list: MarkerData[];
|
|
132
|
+
}
|
|
133
|
+
export type EventCallback = (event: unknown) => void;
|
|
134
|
+
export type SwiperInstance = SwiperClass;
|
|
135
|
+
export type SliderControl = Control & {
|
|
136
|
+
get(prop: string): number;
|
|
137
|
+
set(prop: string, value: number): void;
|
|
138
|
+
element?: HTMLElement;
|
|
139
|
+
setEnable(flag: boolean): void;
|
|
140
|
+
};
|
|
141
|
+
export interface RGB {
|
|
142
|
+
red: number;
|
|
143
|
+
green: number;
|
|
144
|
+
blue: number;
|
|
145
|
+
}
|
|
146
|
+
export interface ControlOptions {
|
|
147
|
+
target?: HTMLElement | string;
|
|
148
|
+
render?: (event: import('ol').MapEvent) => void;
|
|
149
|
+
className?: string;
|
|
150
|
+
tipLabel?: string;
|
|
151
|
+
initialValue?: number;
|
|
152
|
+
character?: string;
|
|
153
|
+
callback?: (this: Control) => void;
|
|
154
|
+
long_callback?: (this: Control) => void;
|
|
155
|
+
cls?: string;
|
|
156
|
+
ui?: MaplatUi;
|
|
157
|
+
zoomInLabel?: string | HTMLElement;
|
|
158
|
+
zoomOutLabel?: string | HTMLElement;
|
|
159
|
+
autoHide?: boolean;
|
|
160
|
+
label?: string | HTMLElement;
|
|
161
|
+
reverse?: boolean;
|
|
162
|
+
}
|
|
163
|
+
export interface ContextMenuItem {
|
|
164
|
+
text?: string;
|
|
165
|
+
classname?: string;
|
|
166
|
+
icon?: string;
|
|
167
|
+
callback?: (obj: {
|
|
168
|
+
coordinate: number[];
|
|
169
|
+
data: unknown;
|
|
170
|
+
}, map: unknown) => void;
|
|
171
|
+
data?: unknown;
|
|
172
|
+
items?: ContextMenuItem[];
|
|
173
|
+
separator?: boolean;
|
|
174
|
+
}
|
|
175
|
+
export interface ContextMenuOptions {
|
|
176
|
+
width?: number;
|
|
177
|
+
defaultItems?: boolean;
|
|
178
|
+
items?: ContextMenuItem[];
|
|
179
|
+
eventType?: string;
|
|
180
|
+
}
|
|
181
|
+
export interface ContextMenuInternalItem {
|
|
182
|
+
id: string;
|
|
183
|
+
submenu: number;
|
|
184
|
+
separator: boolean;
|
|
185
|
+
callback?: (obj: {
|
|
186
|
+
coordinate: number[];
|
|
187
|
+
data: unknown;
|
|
188
|
+
}, map: unknown) => void;
|
|
189
|
+
data?: unknown;
|
|
190
|
+
}
|
|
191
|
+
export interface ContextMenuEvent {
|
|
192
|
+
type: string;
|
|
193
|
+
pixel?: number[];
|
|
194
|
+
coordinate?: number[];
|
|
195
|
+
}
|
package/dist/ui_utils.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import * as bsn from "bootstrap.native";
|
|
2
|
-
export declare function createElement(domStr: string): ChildNode[];
|
|
3
|
-
export declare function prepareModal(modalElm: Element | HTMLElement, options?: any): bsn.Modal;
|
|
4
|
-
export declare function resolveRelativeLink(file: string, fallbackPath: string | null): string;
|
|
5
|
-
export declare function ellips(mapDivDocument: HTMLElement): void;
|
|
6
|
-
export declare function isMaplatSource(source: unknown): source is {
|
|
7
|
-
setGPSMarkerAsync: () => unknown;
|
|
8
|
-
constructor: {
|
|
9
|
-
isBasemap_?: boolean;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
export declare function isBasemap(source: unknown): boolean;
|
|
13
|
-
export declare function encBytes(bytes: number): string;
|
|
1
|
+
import * as bsn from "bootstrap.native";
|
|
2
|
+
export declare function createElement(domStr: string): ChildNode[];
|
|
3
|
+
export declare function prepareModal(modalElm: Element | HTMLElement, options?: any): bsn.Modal;
|
|
4
|
+
export declare function resolveRelativeLink(file: string, fallbackPath: string | null): string;
|
|
5
|
+
export declare function ellips(mapDivDocument: HTMLElement): void;
|
|
6
|
+
export declare function isMaplatSource(source: unknown): source is {
|
|
7
|
+
setGPSMarkerAsync: () => unknown;
|
|
8
|
+
constructor: {
|
|
9
|
+
isBasemap_?: boolean;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare function isBasemap(source: unknown): boolean;
|
|
13
|
+
export declare function encBytes(bytes: number): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maplat/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Maplat is the cool Historical Map/Illustrated Map Viewer.\nIt can transform each map coordinates with nonlinear but homeomorphic projection and makes possible that the maps can collaborate with GPS/accurate maps, without distorting original maps.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/maplat_ui.umd.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@c4h/chuci": "^0.2.5",
|
|
38
38
|
"@c4h/weiwudi": "^0.2.1",
|
|
39
|
-
"@maplat/core": "
|
|
39
|
+
"@maplat/core": "0.13.0",
|
|
40
40
|
"@turf/turf": "^7.3.1",
|
|
41
41
|
"@types/page": "^1.11.9",
|
|
42
42
|
"bootstrap.native": "^5.1.6",
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const browserLanguage = (): string => {
|
|
2
|
+
const navigator = window.navigator;
|
|
3
|
+
const ua = navigator.userAgent.toLowerCase();
|
|
4
|
+
|
|
5
|
+
try {
|
|
6
|
+
let lang;
|
|
7
|
+
// Chrome
|
|
8
|
+
if (ua.indexOf("chrome") != -1) {
|
|
9
|
+
lang = (
|
|
10
|
+
navigator.languages[0] ||
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
(navigator as any).browserLanguage ||
|
|
13
|
+
navigator.language ||
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
(navigator as any).userLanguage
|
|
16
|
+
).split(";");
|
|
17
|
+
return lang[0];
|
|
18
|
+
}
|
|
19
|
+
// Other
|
|
20
|
+
else {
|
|
21
|
+
lang = // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
(
|
|
23
|
+
(navigator as any).browserLanguage ||
|
|
24
|
+
navigator.language ||
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
(navigator as any).userLanguage
|
|
27
|
+
).split(";");
|
|
28
|
+
return lang[0];
|
|
29
|
+
}
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
31
|
+
} catch (_e) {
|
|
32
|
+
return "";
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
export default browserLanguage;
|
package/src/index.ts
CHANGED
|
@@ -77,6 +77,7 @@ export class MaplatUi extends EventTarget {
|
|
|
77
77
|
lastClickCoordinate: Coordinate | undefined;
|
|
78
78
|
lastGPSError: string | undefined;
|
|
79
79
|
selectedMarkerNamespaceID: string | undefined;
|
|
80
|
+
lang = "ja";
|
|
80
81
|
|
|
81
82
|
_t?: TFunction<"translation", undefined>;
|
|
82
83
|
i18n?: i18n;
|
|
@@ -185,7 +186,6 @@ export class MaplatUi extends EventTarget {
|
|
|
185
186
|
}
|
|
186
187
|
|
|
187
188
|
this.restoring = false;
|
|
188
|
-
console.log(`[Debug] Calling updateUrl from ChangeMap`);
|
|
189
189
|
this.updateUrl();
|
|
190
190
|
}
|
|
191
191
|
if (this.waitReadyBridge) {
|
|
@@ -223,16 +223,24 @@ export class MaplatUi extends EventTarget {
|
|
|
223
223
|
if (!dataFragment || typeof dataFragment === "string")
|
|
224
224
|
return dataFragment as string;
|
|
225
225
|
const langs = Object.keys(dataFragment);
|
|
226
|
-
|
|
227
|
-
let key = langs.reduce(
|
|
228
|
-
|
|
229
|
-
prev
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
226
|
+
|
|
227
|
+
let key = langs.reduce(
|
|
228
|
+
(
|
|
229
|
+
prev: string | [string, boolean] | undefined,
|
|
230
|
+
curr: string,
|
|
231
|
+
idx: number,
|
|
232
|
+
arr: string[]
|
|
233
|
+
) => {
|
|
234
|
+
if (curr == this.lang) {
|
|
235
|
+
prev = [dataFragment[curr], true];
|
|
236
|
+
} else if (!prev || (curr == "en" && !prev[1])) {
|
|
237
|
+
prev = [dataFragment[curr], false];
|
|
238
|
+
}
|
|
239
|
+
if (idx == arr.length - 1) return prev[0];
|
|
240
|
+
return prev;
|
|
241
|
+
},
|
|
242
|
+
undefined
|
|
243
|
+
);
|
|
236
244
|
|
|
237
245
|
key = typeof key === "string" ? key : `${key}`;
|
|
238
246
|
if (
|