@maplat/ui 0.10.6 → 0.11.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/LICENSE +223 -223
- package/README.md +128 -91
- package/assets/locales/de/translation.json +71 -0
- package/{locales → assets/locales}/en/translation.json +70 -64
- package/{locales → assets/locales}/ja/translation.json +70 -64
- package/{locales → assets/locales}/ko/translation.json +71 -65
- package/assets/locales/vi/translation.json +71 -0
- package/{locales → assets/locales}/zh/translation.json +71 -65
- package/{locales → assets/locales}/zh-TW/translation.json +71 -65
- package/assets/parts/attr.png +0 -0
- package/assets/parts/border.png +0 -0
- package/assets/parts/compass.png +0 -0
- package/assets/parts/gps.png +0 -0
- package/assets/parts/help.png +0 -0
- package/assets/parts/hide_marker.png +0 -0
- package/assets/parts/home.png +0 -0
- package/assets/parts/marker_list.png +0 -0
- package/assets/parts/share.png +0 -0
- package/dist/absolute_url.d.ts +1 -0
- package/dist/assets/locales/de/translation.json +71 -0
- package/dist/assets/locales/en/translation.json +70 -64
- package/dist/assets/locales/ja/translation.json +70 -64
- package/dist/assets/locales/ko/translation.json +71 -65
- package/dist/assets/locales/vi/translation.json +71 -0
- package/dist/assets/locales/zh/translation.json +71 -65
- package/dist/assets/locales/zh-TW/translation.json +71 -65
- package/dist/contextmenu.d.ts +5 -0
- package/dist/function.d.ts +2 -0
- package/dist/icons.d.ts +7 -0
- package/dist/index.d.ts +64 -0
- package/dist/maplat-ui.es.js +9383 -0
- package/dist/maplat-ui.umd.js +205 -0
- package/dist/maplat_control.d.ts +55 -0
- package/dist/pointer_images.d.ts +2 -0
- package/dist/swiper_ex.d.ts +2 -0
- package/dist/types.d.ts +173 -0
- package/dist/ui_init.d.ts +4 -0
- package/dist/ui_marker.d.ts +9 -0
- package/dist/ui_utils.d.ts +9 -0
- package/less/bootstrap.less +7010 -7010
- package/less/contextmenu.css +8 -0
- package/less/font-awesome.less +51 -31
- package/less/iziToast.less +1732 -1732
- package/less/maplat-specific.less +1038 -652
- package/less/swiper4.css +715 -0
- package/less/ui.less +11 -11
- package/less/ui_packed.less +10 -10
- package/package.json +80 -79
- package/src/{absolute_url.js → absolute_url.ts} +1 -1
- package/src/contextmenu/base.ts +170 -0
- package/src/contextmenu/constants.ts +66 -0
- package/src/contextmenu/cssVars.ts +13 -0
- package/src/contextmenu/helpers/dom.ts +295 -0
- package/src/contextmenu/helpers/mix.ts +120 -0
- package/src/contextmenu/html.ts +161 -0
- package/src/contextmenu/internal.ts +293 -0
- package/src/contextmenu.ts +40 -0
- package/src/function.ts +36 -0
- package/src/icons.ts +46 -0
- package/src/index.ts +520 -0
- package/src/maplat_control.ts +686 -0
- package/src/pointer_images.ts +101 -0
- package/src/{service-worker.js → service-worker/index.ts} +5 -6
- package/src/swiper_augment.d.ts +13 -0
- package/src/{swiper_ex.js → swiper_ex.ts} +14 -10
- package/src/types.d.ts +31 -0
- package/src/types.ts +202 -0
- package/src/ui_init.ts +1066 -0
- package/src/ui_marker.ts +376 -0
- package/src/ui_utils.ts +87 -0
- package/dist/assets/fonts/a8c0074cf70b152b56105e6c4b227bd8.woff +0 -0
- package/dist/assets/fonts/cfeff2e898a64ebe7e6b5ec078b174c3.woff +0 -0
- package/dist/assets/images/09c3ce5a86d600e24f8e85de3a019853.png +0 -0
- package/dist/assets/images/0beac2cb41dfab43ddfd9df80b32b85d.png +0 -0
- package/dist/assets/images/1354b4f40dd58bb0f2a4871cb4ff81d8.png +0 -0
- package/dist/assets/images/2a61e310e46b50b5f8ddd5e905ba9db9.png +0 -0
- package/dist/assets/images/3131423d782cd3ea89a81247065e7f9d.png +0 -0
- package/dist/assets/images/41b2cf0fa604d3f196ca52337d238219.jpg +0 -0
- package/dist/assets/images/558bc7e8b9b6c5f41a7141cddb8cdb5e.png +0 -0
- package/dist/assets/images/56f7003805ed02f8a21199947651db2e.png +0 -0
- package/dist/assets/images/5ba349e3596aca094c41c56966b45dc7.png +0 -0
- package/dist/assets/images/6111b8076a2cf81c73f0e46f41a3af60.png +0 -0
- package/dist/assets/images/6345ee67d554fbfbf484ba4035ad19d9.jpg +0 -0
- package/dist/assets/images/649fce122b354de2ac725ba5f2661955.png +0 -0
- package/dist/assets/images/6a580287dea82c2fb9b214321a375145.png +0 -0
- package/dist/assets/images/6c5dba7f7d76e74c3a8c7c5b1c3fc544.png +0 -0
- package/dist/assets/images/6e1f2f2f6fed3c5cddeb925e7ae75aba.png +0 -0
- package/dist/assets/images/799a0177b0dc540682fa4a2e349a8f4f.png +0 -0
- package/dist/assets/images/7bef6f357e921c43f4f800cfcb757872.png +0 -0
- package/dist/assets/images/7d9d643a903df6f57b8b7386316021e5.png +0 -0
- package/dist/assets/images/7df82bae917b68159f84998182f2fdc6.png +0 -0
- package/dist/assets/images/8e5d0335f6598b8d874ba23ea9fb295f.png +0 -0
- package/dist/assets/images/90c32e751366be22777f3fe40a53fe06.png +0 -0
- package/dist/assets/images/9247459937b9c882303962e42bd8d989.png +0 -0
- package/dist/assets/images/927c34e7b9b2f95c82ba477993117eaf.png +0 -0
- package/dist/assets/images/95e9ca8285131f8ccb6da5052093173c.png +0 -0
- package/dist/assets/images/9a243e0cb0fc43e2a016d5d3aaa330d5.png +0 -0
- package/dist/assets/images/9ac6d81f417d6a5626b7c8d5a087c32b.png +0 -0
- package/dist/assets/images/9d3a01c866095b8b3e8e63f9cf11dd51.png +0 -0
- package/dist/assets/images/9df733bcb29a746cb16b47eedea9fc3a.png +0 -0
- package/dist/assets/images/acc6eab0ba9c470ae20fb4b74135e865.png +0 -0
- package/dist/assets/images/b9ae27f0a01228380dff76a33b605707.jpg +0 -0
- package/dist/assets/images/ba48b220f61a6e1028f1854326f43acd.png +0 -0
- package/dist/assets/images/bf67cc860289b85c0402a4d4f890a3bd.png +0 -0
- package/dist/assets/images/c49f2344772e33256ba24d64b59b20d1.png +0 -0
- package/dist/assets/images/ca6b77b234b18e7bb9b1ccda774da286.png +0 -0
- package/dist/assets/images/cd213169df16398b0017450e31788d73.png +0 -0
- package/dist/assets/images/f101a0974972eeab41189185a5c5b225.png +0 -0
- package/dist/assets/images/f115726e6249018905cca51653e1262c.png +0 -0
- package/dist/assets/images/f7acb820d978ab2dd69e8bf695c574d1.png +0 -0
- package/dist/assets/images/ffea4dd10bf2506aa1e0cd4c61426b42.png +0 -0
- package/dist/assets/maplat.css +0 -19
- package/dist/assets/maplat.css.map +0 -1
- package/dist/assets/maplat.js +0 -3
- package/dist/assets/maplat.js.LICENSE.txt +0 -43
- package/dist/assets/maplat.js.map +0 -1
- package/dist/index.html +0 -125
- package/dist/service-worker.js +0 -3
- package/dist/service-worker.js.LICENSE.txt +0 -1
- package/dist/service-worker.js.map +0 -1
- package/fonts/clarenbd-webfont.woff +0 -0
- package/fonts/fontawesome-webfont.woff +0 -0
- package/legacy/bootstrap-native.js +0 -1935
- package/legacy/detect-element-resize.js +0 -153
- package/legacy/iziToast.js +0 -1301
- package/legacy/page.js +0 -1153
- package/legacy/qrcode.js +0 -616
- package/legacy/sprintf.js +0 -285
- package/less/font-face.less +0 -11
- package/less/font-face_packed.less +0 -11
- package/parts/attr.png +0 -0
- package/parts/blue_marker.png +0 -0
- package/parts/bluedot.png +0 -0
- package/parts/bluedot_small.png +0 -0
- package/parts/bluedot_transparent.png +0 -0
- package/parts/border.png +0 -0
- package/parts/compass.png +0 -0
- package/parts/defaultpin.png +0 -0
- package/parts/defaultpin_selected.png +0 -0
- package/parts/gps.png +0 -0
- package/parts/gsi.jpg +0 -0
- package/parts/gsi_ortho.jpg +0 -0
- package/parts/help.png +0 -0
- package/parts/hide_marker.png +0 -0
- package/parts/home.png +0 -0
- package/parts/osm.jpg +0 -0
- package/parts/red_marker.png +0 -0
- package/parts/redcircle.png +0 -0
- package/parts/share.png +0 -0
- package/src/contextmenu.js +0 -29
- package/src/freeze_locales.js +0 -337
- package/src/function.js +0 -22
- package/src/index.js +0 -1778
- package/src/index_packed.js +0 -8
- package/src/maplat_control.js +0 -808
- package/src/pointer_images.js +0 -81
- /package/{parts → assets/parts}/Maplat.png +0 -0
- /package/{parts → assets/parts}/all_right_reserved.png +0 -0
- /package/{parts → assets/parts}/basemap.png +0 -0
- /package/{parts → assets/parts}/cc0.png +0 -0
- /package/{parts → assets/parts}/cc_by-nc-nd.png +0 -0
- /package/{parts → assets/parts}/cc_by-nc-sa.png +0 -0
- /package/{parts → assets/parts}/cc_by-nc.png +0 -0
- /package/{parts → assets/parts}/cc_by-nd.png +0 -0
- /package/{parts → assets/parts}/cc_by-sa.png +0 -0
- /package/{parts → assets/parts}/cc_by.png +0 -0
- /package/{parts → assets/parts}/favicon.png +0 -0
- /package/{parts → assets/parts}/fullscreen.png +0 -0
- /package/{parts → assets/parts}/loading.png +0 -0
- /package/{parts → assets/parts}/loading_image.png +0 -0
- /package/{parts → assets/parts}/minus.png +0 -0
- /package/{parts → assets/parts}/no_image.png +0 -0
- /package/{parts → assets/parts}/overlay.png +0 -0
- /package/{parts → assets/parts}/pd.png +0 -0
- /package/{parts → assets/parts}/plus.png +0 -0
- /package/{parts → assets/parts}/slider.png +0 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
import { MaplatApp as Core } from "@maplat/core";
|
|
2
|
+
import "ol/ol.css";
|
|
3
|
+
import EventTarget from "ol/events/Target.js";
|
|
4
|
+
import { asArray } from "ol/color";
|
|
5
|
+
|
|
6
|
+
import { Swiper } from "./swiper_ex";
|
|
7
|
+
import { Navigation, Pagination } from "swiper";
|
|
8
|
+
import "swiper/swiper-bundle.css";
|
|
9
|
+
import page from "page";
|
|
10
|
+
import * as bsn from "bootstrap.native";
|
|
11
|
+
import "../less/ui.less";
|
|
12
|
+
|
|
13
|
+
import { uiInit } from "./ui_init";
|
|
14
|
+
import {
|
|
15
|
+
handleMarkerAction,
|
|
16
|
+
showContextMenu,
|
|
17
|
+
xyToMapIDs,
|
|
18
|
+
setHideMarker,
|
|
19
|
+
checkOverlayID,
|
|
20
|
+
handleMarkerActionById
|
|
21
|
+
} from "./ui_marker";
|
|
22
|
+
import type { SliderNew } from "./maplat_control";
|
|
23
|
+
import type ContextMenu from "./contextmenu";
|
|
24
|
+
|
|
25
|
+
import type { Pixel } from "ol/pixel";
|
|
26
|
+
import type { Coordinate } from "ol/coordinate";
|
|
27
|
+
import { resolveRelativeLink, ellips } from "./ui_utils";
|
|
28
|
+
import type { MaplatAppOption, RestoreState, SwiperInstance } from "./types";
|
|
29
|
+
|
|
30
|
+
Swiper.use([Navigation, Pagination]);
|
|
31
|
+
|
|
32
|
+
export class MaplatUi extends EventTarget {
|
|
33
|
+
static createObject(option: MaplatAppOption) {
|
|
34
|
+
const app = new MaplatUi(option);
|
|
35
|
+
return app.waitReady.then(() => app);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
core?: Core;
|
|
39
|
+
appOption: MaplatAppOption;
|
|
40
|
+
waitReady!: Promise<void>;
|
|
41
|
+
waitReadyBridge: unknown;
|
|
42
|
+
pathThatSet?: string;
|
|
43
|
+
swipers: Record<string, SwiperInstance> = {};
|
|
44
|
+
mobile_if: boolean = false;
|
|
45
|
+
ui_func: string = "default";
|
|
46
|
+
datum: string = "default";
|
|
47
|
+
selected_layer: string = "default";
|
|
48
|
+
toms: number = 0;
|
|
49
|
+
cache_messages: Record<string, string> = {};
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
|
+
last_toast: any;
|
|
52
|
+
share_enable!: boolean;
|
|
53
|
+
sliderNew!: SliderNew;
|
|
54
|
+
baseSwiper!: SwiperInstance;
|
|
55
|
+
overlaySwiper!: SwiperInstance;
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
+
sliderCommon: any;
|
|
58
|
+
contextMenu!: ContextMenu;
|
|
59
|
+
splashPromise!: Promise<void>;
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
|
+
_selectCandidateSources?: Record<string, any>;
|
|
62
|
+
appEnvelope?: boolean;
|
|
63
|
+
restoring: boolean = false;
|
|
64
|
+
poiSwiper: SwiperInstance | undefined;
|
|
65
|
+
html!: string;
|
|
66
|
+
enablePoiHtmlNoScroll: boolean = false;
|
|
67
|
+
enableShare: boolean = false;
|
|
68
|
+
enableHideMarker: boolean = false;
|
|
69
|
+
enableBorder: boolean = false;
|
|
70
|
+
enableMarkerList: boolean = false;
|
|
71
|
+
disableNoimage: boolean = false;
|
|
72
|
+
alwaysGpsOn: boolean = false;
|
|
73
|
+
isTouch: boolean = false;
|
|
74
|
+
html_id_seed: string;
|
|
75
|
+
lastClickPixel: Pixel | undefined;
|
|
76
|
+
lastClickCoordinate: Coordinate | undefined;
|
|
77
|
+
|
|
78
|
+
constructor(appOption: MaplatAppOption) {
|
|
79
|
+
super();
|
|
80
|
+
this.html_id_seed = `${Math.floor(Math.random() * 9000) + 1000}`;
|
|
81
|
+
this.appOption = appOption;
|
|
82
|
+
|
|
83
|
+
if (appOption.stateUrl) {
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
85
|
+
page((ctx: any, _next: any) => {
|
|
86
|
+
let pathes = ctx.canonicalPath.split("#!");
|
|
87
|
+
let path = pathes.length > 1 ? pathes[1] : pathes[0];
|
|
88
|
+
console.log(
|
|
89
|
+
`[Debug] Page callback.Canonical: ${ctx.canonicalPath}, Path: ${path} `
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
pathes = path.split("?");
|
|
93
|
+
path = pathes[0];
|
|
94
|
+
if (path === this.pathThatSet) {
|
|
95
|
+
delete this.pathThatSet;
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const restore: RestoreState = {
|
|
99
|
+
transparency: 0,
|
|
100
|
+
position: {
|
|
101
|
+
rotation: 0
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
// Parse "s:map/x:100/..."
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
106
|
+
path.split("/").forEach((state: any) => {
|
|
107
|
+
if (!state) return;
|
|
108
|
+
const line = state.split(":");
|
|
109
|
+
console.log(`[Debug] Parsing state: ${state} `, line);
|
|
110
|
+
switch (line[0]) {
|
|
111
|
+
case "s":
|
|
112
|
+
restore.mapID = line[1];
|
|
113
|
+
break;
|
|
114
|
+
case "b":
|
|
115
|
+
restore.backgroundID = line[1];
|
|
116
|
+
break;
|
|
117
|
+
case "t":
|
|
118
|
+
restore.transparency = parseFloat(line[1]);
|
|
119
|
+
break;
|
|
120
|
+
case "r":
|
|
121
|
+
restore.position!.rotation = parseFloat(line[1]);
|
|
122
|
+
break;
|
|
123
|
+
case "z":
|
|
124
|
+
restore.position!.zoom = parseFloat(line[1]);
|
|
125
|
+
break;
|
|
126
|
+
case "x":
|
|
127
|
+
restore.position!.x = parseFloat(line[1]);
|
|
128
|
+
break;
|
|
129
|
+
case "y":
|
|
130
|
+
restore.position!.y = parseFloat(line[1]);
|
|
131
|
+
break;
|
|
132
|
+
case "sb":
|
|
133
|
+
restore.showBorder = !!parseInt(line[1]);
|
|
134
|
+
break;
|
|
135
|
+
case "hm":
|
|
136
|
+
restore.hideMarker = !!parseInt(line[1]);
|
|
137
|
+
break;
|
|
138
|
+
case "hl":
|
|
139
|
+
restore.hideLayer = line[1];
|
|
140
|
+
break;
|
|
141
|
+
case "om":
|
|
142
|
+
restore.openedMarker = line[1];
|
|
143
|
+
break;
|
|
144
|
+
case "c":
|
|
145
|
+
if (this.core) {
|
|
146
|
+
const modalElm =
|
|
147
|
+
this.core!.mapDivDocument!.querySelector(".modalBase")!;
|
|
148
|
+
const modal = new bsn.Modal(modalElm, {
|
|
149
|
+
root: this.core!.mapDivDocument!
|
|
150
|
+
});
|
|
151
|
+
modal.hide();
|
|
152
|
+
}
|
|
153
|
+
break;
|
|
154
|
+
case "mobile_if":
|
|
155
|
+
this.mobile_if = line[1] === "true";
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
if (!this.core) {
|
|
160
|
+
if (restore.mapID) {
|
|
161
|
+
console.log(
|
|
162
|
+
`[Debug] Init with restore: `,
|
|
163
|
+
JSON.parse(JSON.stringify(restore))
|
|
164
|
+
);
|
|
165
|
+
appOption.restore = restore;
|
|
166
|
+
this.restoring = true;
|
|
167
|
+
}
|
|
168
|
+
const preRot = restore.position
|
|
169
|
+
? restore.position.rotation
|
|
170
|
+
: "undefined";
|
|
171
|
+
console.log(`[Debug] Before initializer: rotation = ${preRot} `);
|
|
172
|
+
|
|
173
|
+
this.initializer(appOption).then(() => {
|
|
174
|
+
this.core!.waitReady.then(() => {
|
|
175
|
+
// Fix: Manually apply rotation as Core 0.11.1 preserves it but fails to apply it view-side
|
|
176
|
+
// if (restore.position && restore.position.rotation !== undefined) {
|
|
177
|
+
// console.log(`[Debug] Manually applying rotation: ${ restore.position.rotation } `);
|
|
178
|
+
// this.core!.mapObject.getView().setRotation(restore.position.rotation);
|
|
179
|
+
// }
|
|
180
|
+
// Fix: Verify transparency state before updating URL
|
|
181
|
+
if (this.sliderNew) {
|
|
182
|
+
// Ensure map transparency matches restore if slider is ready
|
|
183
|
+
const currentTrans = this.sliderNew.get("slidervalue") * 100;
|
|
184
|
+
console.log(`[Debug] Slider transparency: ${currentTrans} `);
|
|
185
|
+
} else {
|
|
186
|
+
console.log(`[Debug] Slider not ready yet`);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
this.restoring = false;
|
|
190
|
+
console.log(`[Debug] Calling updateUrl from Init`);
|
|
191
|
+
this.updateUrl();
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
} else if (restore.mapID) {
|
|
195
|
+
console.log(
|
|
196
|
+
`[Debug] ChangeMap with restore: `,
|
|
197
|
+
JSON.parse(JSON.stringify(restore))
|
|
198
|
+
);
|
|
199
|
+
this.restoring = true;
|
|
200
|
+
|
|
201
|
+
this.core!.waitReady.then(() => {
|
|
202
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
203
|
+
const ret = this.core!.changeMap(restore.mapID!, restore as any);
|
|
204
|
+
Promise.resolve(ret).then(() => {
|
|
205
|
+
// Fix: Manually apply rotation after changeMap
|
|
206
|
+
// if (restore.position && restore.position.rotation !== undefined) {
|
|
207
|
+
// console.log(`[Debug] Manually applying rotation after changeMap: ${ restore.position.rotation } `);
|
|
208
|
+
// this.core!.mapObject.getView().setRotation(restore.position.rotation);
|
|
209
|
+
// }
|
|
210
|
+
|
|
211
|
+
// Update transparency slider if needed
|
|
212
|
+
if (this.sliderNew) {
|
|
213
|
+
const t = restore.transparency || 0;
|
|
214
|
+
const val = t / 100;
|
|
215
|
+
this.sliderNew.set("slidervalue", val);
|
|
216
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
217
|
+
if ((this.sliderNew as any).element) {
|
|
218
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
219
|
+
(this.sliderNew as any).element.value = (1 - val).toString();
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
this.restoring = false;
|
|
224
|
+
console.log(`[Debug] Calling updateUrl from ChangeMap`);
|
|
225
|
+
this.updateUrl();
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
page({
|
|
231
|
+
hashbang: true
|
|
232
|
+
});
|
|
233
|
+
page();
|
|
234
|
+
this.waitReady = new Promise((resolve, _reject) => {
|
|
235
|
+
this.waitReadyBridge = resolve;
|
|
236
|
+
});
|
|
237
|
+
} else {
|
|
238
|
+
this.waitReady = this.initializer(appOption);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
243
|
+
async initializer(appOption: any) {
|
|
244
|
+
return uiInit(this, appOption);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
248
|
+
handleMarkerAction(data: any) {
|
|
249
|
+
handleMarkerAction(this, data);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
253
|
+
showContextMenu(list: any[]) {
|
|
254
|
+
showContextMenu(this, list);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
258
|
+
async xyToMapIDs(xy: any, threshold = 10) {
|
|
259
|
+
return xyToMapIDs(this, xy, threshold);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
263
|
+
setShowBorder(flag: any) {
|
|
264
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
265
|
+
this.core!.requestUpdateState({ showBorder: flag ? 1 : 0 } as any);
|
|
266
|
+
this.updateEnvelope();
|
|
267
|
+
if (flag) {
|
|
268
|
+
this.core!.mapDivDocument!.classList.add("show-border");
|
|
269
|
+
} else {
|
|
270
|
+
this.core!.mapDivDocument!.classList.remove("show-border");
|
|
271
|
+
}
|
|
272
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
273
|
+
if (this.core!.restoreSession as any) {
|
|
274
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
275
|
+
this.core!.requestUpdateState({ showBorder: flag ? 1 : 0 } as any);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
280
|
+
setHideMarker(flag: any) {
|
|
281
|
+
setHideMarker(this, flag);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
handleMarkerActionById(markerId: string) {
|
|
285
|
+
handleMarkerActionById(this, markerId);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
updateUrl() {
|
|
289
|
+
if (!this.appOption.stateUrl) return;
|
|
290
|
+
if (this.restoring) return;
|
|
291
|
+
|
|
292
|
+
const map = this.core!.mapObject;
|
|
293
|
+
if (!map) return;
|
|
294
|
+
const view = map.getView();
|
|
295
|
+
const center = view.getCenter();
|
|
296
|
+
const zoom = view.getZoom();
|
|
297
|
+
const rotation = view.getRotation();
|
|
298
|
+
|
|
299
|
+
const currentMap = this.core!.from ? this.core!.from.mapID : "";
|
|
300
|
+
if (!currentMap) return;
|
|
301
|
+
|
|
302
|
+
// Background ID
|
|
303
|
+
let backMap = "";
|
|
304
|
+
if (this.baseSwiper) {
|
|
305
|
+
const slide = this.baseSwiper.slides[this.baseSwiper.activeIndex];
|
|
306
|
+
|
|
307
|
+
if (slide) {
|
|
308
|
+
backMap = slide.getAttribute("data") || "";
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
const transparency = this.sliderNew
|
|
313
|
+
? this.sliderNew.get("slidervalue") * 100
|
|
314
|
+
: 0;
|
|
315
|
+
|
|
316
|
+
// Legacy format: s:map/b:back/... (no leading slash, prepended with #!)
|
|
317
|
+
let path = `s:${currentMap}`;
|
|
318
|
+
|
|
319
|
+
if (backMap && backMap !== currentMap) {
|
|
320
|
+
path += `/b:${backMap}`;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (transparency > 0) {
|
|
324
|
+
path += `/t:${transparency}`;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
path += `/x:${center[0]}`;
|
|
328
|
+
path += `/y:${center[1]}`;
|
|
329
|
+
path += `/z:${zoom}`;
|
|
330
|
+
|
|
331
|
+
if (rotation !== 0) {
|
|
332
|
+
path += `/r:${(rotation * 180) / Math.PI}`;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// Options
|
|
336
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
337
|
+
if ((this.core!.stateBuffer as any).showBorder) path += `/sb:1`;
|
|
338
|
+
if (this.core!.mapDivDocument!.classList.contains("hide-marker"))
|
|
339
|
+
path += `/hm:1`;
|
|
340
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
341
|
+
if (this.enableMarkerList && (this.core!.stateBuffer as any).markerList)
|
|
342
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
343
|
+
path += `/om:${(this.core!.stateBuffer as any).markerList}`;
|
|
344
|
+
|
|
345
|
+
if (this.pathThatSet !== path) {
|
|
346
|
+
this.pathThatSet = path;
|
|
347
|
+
page(`#!${path}`);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
updateEnvelope() {
|
|
352
|
+
if (!this.core!.mapObject) return;
|
|
353
|
+
|
|
354
|
+
this.core!.mapObject.resetEnvelope();
|
|
355
|
+
if (this._selectCandidateSources) {
|
|
356
|
+
Object.keys(this._selectCandidateSources).forEach(key => {
|
|
357
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
358
|
+
if ((this.core!.mapObject as any).removeEnvelope) {
|
|
359
|
+
console.log(`[Debug] Removing envelope for ${key}`);
|
|
360
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
361
|
+
(this.core!.mapObject as any).removeEnvelope(
|
|
362
|
+
this._selectCandidateSources![key]
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
this._selectCandidateSources = {};
|
|
369
|
+
|
|
370
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
371
|
+
if ((this.core!.stateBuffer as any).showBorder) {
|
|
372
|
+
if (!this.core!.from) return;
|
|
373
|
+
|
|
374
|
+
let activeOverlayId: string | null = null;
|
|
375
|
+
if (this.overlaySwiper) {
|
|
376
|
+
const slide = this.overlaySwiper.slides[this.overlaySwiper.activeIndex];
|
|
377
|
+
if (slide) activeOverlayId = slide.getAttribute("data");
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
Object.keys(this.core!.cacheHash!)
|
|
381
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
382
|
+
.filter((key: any) => this.core!.cacheHash[key].envelope)
|
|
383
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
384
|
+
.map((key: any) => {
|
|
385
|
+
const source = this.core!.cacheHash[key];
|
|
386
|
+
const isActive = key === activeOverlayId;
|
|
387
|
+
|
|
388
|
+
const xyPromises =
|
|
389
|
+
key === this.core!.from!.mapID &&
|
|
390
|
+
typeof source.xy2SysCoord === "function"
|
|
391
|
+
? [
|
|
392
|
+
[0, 0],
|
|
393
|
+
[source.width, 0],
|
|
394
|
+
[source.width, source.height],
|
|
395
|
+
[0, source.height],
|
|
396
|
+
[0, 0]
|
|
397
|
+
].map(xy => Promise.resolve(source.xy2SysCoord(xy)))
|
|
398
|
+
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
399
|
+
source.envelope.geometry.coordinates[0].map((coord: any) =>
|
|
400
|
+
this.core!.from!.merc2SysCoordAsync(coord)
|
|
401
|
+
);
|
|
402
|
+
|
|
403
|
+
Promise.all(xyPromises).then(xys => {
|
|
404
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
405
|
+
const options: any = {
|
|
406
|
+
color: source.envelopeColor,
|
|
407
|
+
width: 2,
|
|
408
|
+
lineDash: [6, 6]
|
|
409
|
+
};
|
|
410
|
+
this.core!.mapObject.setEnvelope(xys, options);
|
|
411
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
412
|
+
if (isActive && (this.core!.mapObject as any).setFillEnvelope) {
|
|
413
|
+
console.log(`[Debug] Setting fill envelope for ${key}`);
|
|
414
|
+
|
|
415
|
+
const color = asArray(source.envelopeColor || "#000000");
|
|
416
|
+
|
|
417
|
+
color[3] = 0.4;
|
|
418
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
419
|
+
const fillHandle = (this.core!.mapObject as any).setFillEnvelope(
|
|
420
|
+
xys,
|
|
421
|
+
null,
|
|
422
|
+
{ color }
|
|
423
|
+
);
|
|
424
|
+
this._selectCandidateSources![key] = fillHandle;
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
432
|
+
resolveRelativeLink(file: any, fallbackPath: any) {
|
|
433
|
+
return resolveRelativeLink(file, fallbackPath);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
437
|
+
checkOverlayID(mapID: any) {
|
|
438
|
+
return checkOverlayID(this, mapID);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
areaIndex(xys: number[][]) {
|
|
442
|
+
return (
|
|
443
|
+
0.5 *
|
|
444
|
+
Math.abs(
|
|
445
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
446
|
+
[0, 1, 2, 3].reduce((prev: any, _curr: any, i: any) => {
|
|
447
|
+
const xy1 = xys[i];
|
|
448
|
+
const xy2 = xys[i + 1];
|
|
449
|
+
return prev + (xy1[0] - xy2[0]) * (xy1[1] + xy2[1]);
|
|
450
|
+
}, 0)
|
|
451
|
+
)
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
getShareUrl(type: string) {
|
|
456
|
+
if (type === "view") {
|
|
457
|
+
return window.location.href;
|
|
458
|
+
}
|
|
459
|
+
// app
|
|
460
|
+
return window.location.href.split("?")[0].split("#")[0];
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
showToast(message: string, target?: HTMLElement) {
|
|
464
|
+
let toast = document.querySelector(".custom-toast") as HTMLElement;
|
|
465
|
+
if (!toast) {
|
|
466
|
+
toast = document.createElement("div");
|
|
467
|
+
toast.className = "custom-toast";
|
|
468
|
+
document.body.appendChild(toast);
|
|
469
|
+
}
|
|
470
|
+
(toast as HTMLElement).innerText = message;
|
|
471
|
+
|
|
472
|
+
if (target) {
|
|
473
|
+
const parent = target.closest(".recipient");
|
|
474
|
+
const rect = (parent || target).getBoundingClientRect();
|
|
475
|
+
toast.style.position = "fixed";
|
|
476
|
+
toast.style.left = `${rect.left + rect.width / 2}px`;
|
|
477
|
+
toast.style.top = `${rect.top + rect.height / 2}px`;
|
|
478
|
+
toast.style.transform = "translate(-50%, -50%)";
|
|
479
|
+
toast.style.bottom = "auto";
|
|
480
|
+
toast.style.margin = "0";
|
|
481
|
+
} else {
|
|
482
|
+
toast.style.position = "fixed";
|
|
483
|
+
toast.style.left = "50%";
|
|
484
|
+
toast.style.bottom = "30px";
|
|
485
|
+
toast.style.top = "auto";
|
|
486
|
+
toast.style.transform = "";
|
|
487
|
+
toast.style.marginLeft = "-125px";
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
toast.classList.add("show");
|
|
491
|
+
|
|
492
|
+
setTimeout(() => {
|
|
493
|
+
toast!.classList.remove("show");
|
|
494
|
+
}, 1500);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
modalSetting(type: string) {
|
|
498
|
+
const modalElm = this.core!.mapDivDocument!.querySelector(".modalBase")!;
|
|
499
|
+
modalElm.classList.remove(
|
|
500
|
+
"modal_load",
|
|
501
|
+
"modal_poi",
|
|
502
|
+
"modal_share",
|
|
503
|
+
"modal_help",
|
|
504
|
+
"modal_gpsW",
|
|
505
|
+
"modal_gpsD",
|
|
506
|
+
"modal_map",
|
|
507
|
+
"modal_marker_list"
|
|
508
|
+
);
|
|
509
|
+
modalElm.classList.add(`modal_${type}`);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
ellips() {
|
|
513
|
+
ellips(this.core!.mapDivDocument!);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
remove() {
|
|
517
|
+
this.core!.remove();
|
|
518
|
+
delete this.core;
|
|
519
|
+
}
|
|
520
|
+
}
|