@maplat/ui 0.10.5 → 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/README.md +38 -1
- package/assets/locales/de/translation.json +71 -0
- package/{locales → assets/locales}/en/translation.json +12 -6
- package/{locales → assets/locales}/ja/translation.json +12 -6
- package/{locales → assets/locales}/ko/translation.json +12 -6
- package/assets/locales/vi/translation.json +71 -0
- package/{locales → assets/locales}/zh/translation.json +12 -6
- package/{locales → assets/locales}/zh-TW/translation.json +12 -6
- 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 +12 -6
- package/dist/assets/locales/ja/translation.json +12 -6
- package/dist/assets/locales/ko/translation.json +12 -6
- package/dist/assets/locales/vi/translation.json +71 -0
- package/dist/assets/locales/zh/translation.json +12 -6
- package/dist/assets/locales/zh-TW/translation.json +12 -6
- 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/contextmenu.css +8 -0
- package/less/font-awesome.less +48 -28
- package/less/maplat-specific.less +452 -66
- package/less/swiper4.css +715 -0
- package/less/ui.less +5 -5
- package/less/ui_packed.less +3 -3
- package/package.json +107 -106
- 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 -39
- 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 -1762
- package/src/index_packed.js +0 -8
- package/src/maplat_control.js +0 -814
- 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/ui_marker.ts
ADDED
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import { createElement } from "@maplat/core";
|
|
2
|
+
import * as bsn from "bootstrap.native";
|
|
3
|
+
// import { Swiper } from "./swiper_ex";
|
|
4
|
+
import "@c4h/chuci";
|
|
5
|
+
import { point, polygon, booleanPointInPolygon } from "@turf/turf";
|
|
6
|
+
import { resolveRelativeLink } from "./ui_utils";
|
|
7
|
+
|
|
8
|
+
function detectMediaType(src: string): string {
|
|
9
|
+
if (src.includes("youtube.com") || src.includes("youtu.be")) {
|
|
10
|
+
return "youtube";
|
|
11
|
+
}
|
|
12
|
+
const ext = src.split(".").pop()?.toLowerCase();
|
|
13
|
+
switch (ext) {
|
|
14
|
+
case "mp4":
|
|
15
|
+
case "webm":
|
|
16
|
+
return "video";
|
|
17
|
+
case "obj":
|
|
18
|
+
return "3dmodel";
|
|
19
|
+
case "splat":
|
|
20
|
+
case "ply":
|
|
21
|
+
return "gaussian";
|
|
22
|
+
default:
|
|
23
|
+
return "image";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
import type { MaplatUi } from "./index";
|
|
27
|
+
import type { MarkerData, MediaSetting, MediaObject } from "./types";
|
|
28
|
+
|
|
29
|
+
export function poiWebControl(
|
|
30
|
+
ui: MaplatUi,
|
|
31
|
+
div: HTMLElement,
|
|
32
|
+
data: MarkerData
|
|
33
|
+
) {
|
|
34
|
+
// let poiSwiper: SwiperInstance | undefined;
|
|
35
|
+
div.innerHTML = "";
|
|
36
|
+
|
|
37
|
+
if (data.url || data.html) {
|
|
38
|
+
const htmlDiv =
|
|
39
|
+
createElement(`<div class="${ui.enablePoiHtmlNoScroll ? "" : " embed-responsive embed-responsive-60vh"}">
|
|
40
|
+
<iframe class="poi_iframe iframe_poi" frameborder="0" src=""${ui.enablePoiHtmlNoScroll ? ` onload="window.addEventListener('message', (e) =>{if (e.data[0] == 'setHeight') {this.style.height = e.data[1];}});" scrolling="no"` : ""}></iframe>
|
|
41
|
+
</div>`)[0] as HTMLElement;
|
|
42
|
+
div.appendChild(htmlDiv);
|
|
43
|
+
const iframe = htmlDiv.querySelector(".poi_iframe") as HTMLIFrameElement;
|
|
44
|
+
|
|
45
|
+
if (data.html) {
|
|
46
|
+
const loadEvent = (event: Event) => {
|
|
47
|
+
if (!event.currentTarget) return;
|
|
48
|
+
event.currentTarget.removeEventListener(event.type, loadEvent);
|
|
49
|
+
const cssLink = createElement(
|
|
50
|
+
'<style type="text/css">html, body { height: 100vh; }\n img { width: 100%; }</style>'
|
|
51
|
+
);
|
|
52
|
+
const jsLink = createElement(
|
|
53
|
+
`<script>
|
|
54
|
+
const heightGetter = document.querySelector("#heightGetter");
|
|
55
|
+
const resizeObserver = new ResizeObserver(entries => {
|
|
56
|
+
window.parent.postMessage(["setHeight", (entries[0].target.clientHeight + 16) + "px"], "*");
|
|
57
|
+
});
|
|
58
|
+
if(heightGetter) resizeObserver.observe(heightGetter);
|
|
59
|
+
</script>`
|
|
60
|
+
);
|
|
61
|
+
iframe.contentDocument!.head.appendChild(cssLink[0]);
|
|
62
|
+
iframe.contentDocument!.head.appendChild(jsLink[0]);
|
|
63
|
+
};
|
|
64
|
+
iframe.addEventListener("load", loadEvent);
|
|
65
|
+
iframe.removeAttribute("src");
|
|
66
|
+
iframe.setAttribute(
|
|
67
|
+
"srcdoc",
|
|
68
|
+
`<div id="heightGetter">${ui.core!.translate(data.html) || ""}</div>`
|
|
69
|
+
);
|
|
70
|
+
} else {
|
|
71
|
+
iframe.removeAttribute("srcdoc");
|
|
72
|
+
iframe.setAttribute("src", ui.core!.translate(data.url) || "");
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
const slides: string[] = [];
|
|
76
|
+
const mediaList = (data.media || data.image) as MediaSetting[] | undefined;
|
|
77
|
+
|
|
78
|
+
if (mediaList) {
|
|
79
|
+
const inputs = Array.isArray(mediaList) ? mediaList : [mediaList];
|
|
80
|
+
|
|
81
|
+
inputs.forEach((item: MediaSetting) => {
|
|
82
|
+
let mediaObj: MediaObject;
|
|
83
|
+
if (typeof item === "string") {
|
|
84
|
+
mediaObj = {
|
|
85
|
+
src: item,
|
|
86
|
+
type: detectMediaType(item)
|
|
87
|
+
};
|
|
88
|
+
} else {
|
|
89
|
+
mediaObj = { ...item }; // Clone to avoid mutation if needed
|
|
90
|
+
if (!mediaObj.type) {
|
|
91
|
+
mediaObj.type = detectMediaType(mediaObj.src);
|
|
92
|
+
}
|
|
93
|
+
// desc compatibility for caption
|
|
94
|
+
if (mediaObj.desc && !mediaObj.caption) {
|
|
95
|
+
mediaObj.caption = mediaObj.desc;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const tmpSrc = resolveRelativeLink(mediaObj.src, "img"); // Assume 'img' type resolve works for most media assets or general path
|
|
100
|
+
|
|
101
|
+
let slideAttrs = `image-url="${tmpSrc}" image-type="${mediaObj.type}"`;
|
|
102
|
+
|
|
103
|
+
if (mediaObj.thumbnail) {
|
|
104
|
+
slideAttrs += ` thumbnail-url="${resolveRelativeLink(mediaObj.thumbnail, "img")}"`;
|
|
105
|
+
} else {
|
|
106
|
+
// Default thumbnail to src for images, but for others (video etc) this might fail if no explicit thumb provided.
|
|
107
|
+
// Legacy behavior was image-only so src was thumb.
|
|
108
|
+
// For non-image types without thumbnail, Chuci might handle or show placeholder.
|
|
109
|
+
// Let's use src as thumb for images or if nothing else.
|
|
110
|
+
if (mediaObj.type === "image") {
|
|
111
|
+
slideAttrs += ` thumbnail-url="${tmpSrc}"`;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Map other attributes
|
|
116
|
+
Object.keys(mediaObj).forEach(key => {
|
|
117
|
+
if (["src", "type", "thumbnail", "desc"].includes(key)) return;
|
|
118
|
+
const val = mediaObj[key];
|
|
119
|
+
if (typeof val === "boolean") {
|
|
120
|
+
if (val) slideAttrs += ` ${key}`;
|
|
121
|
+
} else if (val !== undefined && val !== null) {
|
|
122
|
+
slideAttrs += ` ${key}="${val}"`;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
slides.push(`<cc-swiper-slide ${slideAttrs}></cc-swiper-slide>`);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
// Logic for noimage skipped/simplified as requested in previous interactions
|
|
130
|
+
|
|
131
|
+
const htmlDiv = createElement(`<div class="poi_data">
|
|
132
|
+
<div class="col-xs-12 poi_img_swiper">
|
|
133
|
+
<cc-swiper>${slides.join("")}</cc-swiper>
|
|
134
|
+
</div>
|
|
135
|
+
<p class="recipient poi_address"></p>
|
|
136
|
+
<p class="recipient poi_desc"></p>
|
|
137
|
+
</div>`)[0] as HTMLElement;
|
|
138
|
+
div.appendChild(htmlDiv);
|
|
139
|
+
|
|
140
|
+
// Inject custom CSS for Swiper if not exists (global check)
|
|
141
|
+
if (!document.getElementById("poi-swiper-style")) {
|
|
142
|
+
const style = document.createElement("style");
|
|
143
|
+
style.id = "poi-swiper-style";
|
|
144
|
+
style.innerHTML = `
|
|
145
|
+
cc-swiper { --cc-slider-theme-color: #007aff; --cc-slider-navigation-color: #007aff; height: 300px; }
|
|
146
|
+
cc-viewer { --cc-viewer-z-index: 100000; }
|
|
147
|
+
`;
|
|
148
|
+
document.head.appendChild(style);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
(htmlDiv.querySelector(".poi_address") as HTMLElement).innerText =
|
|
152
|
+
ui.core!.translate(data.address) || "";
|
|
153
|
+
(htmlDiv.querySelector(".poi_desc") as HTMLElement).innerHTML = (
|
|
154
|
+
ui.core!.translate(data.desc) || ""
|
|
155
|
+
).replace(/\n/g, "<br>");
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function handleMarkerAction(ui: MaplatUi, data: MarkerData) {
|
|
162
|
+
const modalElm = ui.core!.mapDivDocument!.querySelector(".modalBase")!;
|
|
163
|
+
const modal = bsn.Modal.getInstance(modalElm) || new bsn.Modal(modalElm);
|
|
164
|
+
|
|
165
|
+
const closeBtns = modalElm.querySelectorAll(".close, .modal-footer button");
|
|
166
|
+
for (let i = 0; i < closeBtns.length; i++) {
|
|
167
|
+
closeBtns[i].addEventListener("click", () => {
|
|
168
|
+
modal.hide();
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (data.directgo) {
|
|
173
|
+
let blank = false;
|
|
174
|
+
let href = "";
|
|
175
|
+
if (typeof data.directgo == "string") {
|
|
176
|
+
href = data.directgo;
|
|
177
|
+
} else {
|
|
178
|
+
href = data.directgo.href;
|
|
179
|
+
blank = data.directgo.blank || false;
|
|
180
|
+
}
|
|
181
|
+
if (blank) {
|
|
182
|
+
window.open(href, "_blank");
|
|
183
|
+
} else {
|
|
184
|
+
window.location.href = href;
|
|
185
|
+
}
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const titleEl =
|
|
190
|
+
ui.core!.mapDivDocument!.querySelector(".modal_poi_title") ||
|
|
191
|
+
ui.core!.mapDivDocument!.querySelector(".modal_title");
|
|
192
|
+
if (titleEl)
|
|
193
|
+
(titleEl as HTMLElement).innerText = ui.core!.translate(data.name) || "";
|
|
194
|
+
|
|
195
|
+
// Prepare container - ensure poi_web_div exists or target it
|
|
196
|
+
let poiWebDiv = ui.core!.mapDivDocument!.querySelector(".poi_web_div");
|
|
197
|
+
if (!poiWebDiv) {
|
|
198
|
+
// Fallback or create? simpler to assume ui_init will be updated,
|
|
199
|
+
// but for robustness we can clear modal_poi_content and append it if missing,
|
|
200
|
+
// OR target existing .poi_web (renaming it effectively).
|
|
201
|
+
// Let's assume ui_init.ts will provide .poi_web_div.
|
|
202
|
+
// If not present, we grab .modal_poi_content and insert it?
|
|
203
|
+
const modalPoiContent =
|
|
204
|
+
ui.core!.mapDivDocument!.querySelector(".modal_poi_content");
|
|
205
|
+
if (modalPoiContent) {
|
|
206
|
+
poiWebDiv = createElement(
|
|
207
|
+
'<div class="poi_web_div"></div>'
|
|
208
|
+
)[0] as HTMLElement;
|
|
209
|
+
// Prepend to avoid messing with share buttons at bottom?
|
|
210
|
+
modalPoiContent.insertBefore(poiWebDiv, modalPoiContent.firstChild);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
poiWebControl(ui, poiWebDiv as HTMLElement, data);
|
|
215
|
+
|
|
216
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
217
|
+
const hiddenFunc = (_event: any) => {
|
|
218
|
+
modalElm.removeEventListener("hidden.bs.modal", hiddenFunc, false);
|
|
219
|
+
ui.core!.unselectMarker();
|
|
220
|
+
};
|
|
221
|
+
modalElm.addEventListener("hidden.bs.modal", hiddenFunc, false);
|
|
222
|
+
|
|
223
|
+
ui.core!.selectMarker(data.namespaceID);
|
|
224
|
+
ui.modalSetting("poi");
|
|
225
|
+
modal.show();
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export function showContextMenu(ui: MaplatUi, list: MarkerData[]) {
|
|
229
|
+
if (!ui.contextMenu) return;
|
|
230
|
+
|
|
231
|
+
ui.contextMenu.clear();
|
|
232
|
+
ui.contextMenu.extend(list);
|
|
233
|
+
|
|
234
|
+
const pixel = ui.lastClickPixel;
|
|
235
|
+
const coordinate = ui.lastClickCoordinate;
|
|
236
|
+
|
|
237
|
+
if (!pixel) {
|
|
238
|
+
console.warn("[Debug] No lastClickPixel for ContextMenu");
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const openHandler = () => {
|
|
243
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
244
|
+
(ui.contextMenu as any).un("open", openHandler);
|
|
245
|
+
const closeHandler = () => {
|
|
246
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
247
|
+
(ui.contextMenu as any).un("close", closeHandler);
|
|
248
|
+
};
|
|
249
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
250
|
+
(ui.contextMenu as any).on("close", closeHandler);
|
|
251
|
+
};
|
|
252
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
253
|
+
(ui.contextMenu as any).on("open", openHandler);
|
|
254
|
+
|
|
255
|
+
// Need direct access to internal openMenu if possible, or standard open
|
|
256
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
257
|
+
(ui.contextMenu as any).Internal?.openMenu(pixel, coordinate);
|
|
258
|
+
|
|
259
|
+
// One-time click to close (mimic legacy)
|
|
260
|
+
const viewport = ui.core!.mapObject.getViewport();
|
|
261
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
262
|
+
const closeMenuHandler = (e: any) => {
|
|
263
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
264
|
+
if ((ui.contextMenu as any).Internal.opened) {
|
|
265
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
266
|
+
(ui.contextMenu as any).Internal?.closeMenu();
|
|
267
|
+
e.stopPropagation();
|
|
268
|
+
viewport.removeEventListener(e.type, closeMenuHandler, false);
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
viewport.addEventListener("pointerdown", closeMenuHandler, false);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
275
|
+
export async function xyToMapIDs(ui: MaplatUi, xy: any, threshold = 10) {
|
|
276
|
+
const point_ = point(xy);
|
|
277
|
+
|
|
278
|
+
const map = ui.core!.mapObject;
|
|
279
|
+
const size = map.getSize();
|
|
280
|
+
const extent = [[0, 0], [size[0], 0], size, [0, size[1]], [0, 0]];
|
|
281
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
282
|
+
const sysCoords = extent.map((pixel: any) =>
|
|
283
|
+
map.getCoordinateFromPixel(pixel)
|
|
284
|
+
);
|
|
285
|
+
const mercs = await (typeof ui.core!.from!.xy2SysCoord !== "function" // ERROR HERE - wait, index.ts line 1273 - checking source
|
|
286
|
+
? Promise.resolve(sysCoords)
|
|
287
|
+
: Promise.all(
|
|
288
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
289
|
+
sysCoords.map((sysCoord: any) =>
|
|
290
|
+
ui.core!.from!.sysCoord2MercAsync(sysCoord)
|
|
291
|
+
)
|
|
292
|
+
));
|
|
293
|
+
const areaIndex = ui.areaIndex(mercs);
|
|
294
|
+
|
|
295
|
+
return Promise.all(
|
|
296
|
+
Object.keys(ui.core!.cacheHash!)
|
|
297
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
298
|
+
.filter((key: any) => ui.core!.cacheHash[key].envelope)
|
|
299
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
300
|
+
.map((key: any) => {
|
|
301
|
+
const source = ui.core!.cacheHash[key];
|
|
302
|
+
return Promise.all([
|
|
303
|
+
Promise.resolve(source),
|
|
304
|
+
Promise.all(
|
|
305
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
306
|
+
source.envelope.geometry.coordinates[0].map((coord: any) =>
|
|
307
|
+
ui.core!.from!.merc2SysCoordAsync(coord)
|
|
308
|
+
)
|
|
309
|
+
)
|
|
310
|
+
]);
|
|
311
|
+
})
|
|
312
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
313
|
+
).then((sources: any) => {
|
|
314
|
+
const mapIDs = sources
|
|
315
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
316
|
+
.reduce((prev: any, curr: any) => {
|
|
317
|
+
const source = curr[0];
|
|
318
|
+
const mercXys = curr[1];
|
|
319
|
+
if (source.mapID !== ui.core!.from!.mapID) {
|
|
320
|
+
const polygon_ = polygon([mercXys]);
|
|
321
|
+
if (booleanPointInPolygon(point_, polygon_)) {
|
|
322
|
+
prev.push(source);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return prev;
|
|
326
|
+
}, [])
|
|
327
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
328
|
+
.filter((source: any) => source.envelopeAreaIndex / areaIndex < threshold)
|
|
329
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
330
|
+
.sort((a: any, b: any) => a.envelopeAreaIndex - b.envelopeAreaIndex)
|
|
331
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
332
|
+
.map((source: any) => source.mapID);
|
|
333
|
+
return mapIDs;
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export function setHideMarker(ui: MaplatUi, flag: boolean) {
|
|
338
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
339
|
+
ui.core!.requestUpdateState({ hideMarker: flag ? 1 : 0 } as any);
|
|
340
|
+
if (flag) {
|
|
341
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
342
|
+
if ((ui.core as any).hideAllMarkers) {
|
|
343
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
344
|
+
(ui.core as any).hideAllMarkers();
|
|
345
|
+
}
|
|
346
|
+
ui.core!.mapDivDocument!.classList.add("hide-marker");
|
|
347
|
+
} else {
|
|
348
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
349
|
+
if ((ui.core as any).showAllMarkers) {
|
|
350
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
351
|
+
(ui.core as any).showAllMarkers();
|
|
352
|
+
}
|
|
353
|
+
ui.core!.mapDivDocument!.classList.remove("hide-marker");
|
|
354
|
+
}
|
|
355
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
356
|
+
if (ui.core!.restoreSession as any) {
|
|
357
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
358
|
+
ui.core!.requestUpdateState({ hideMarker: flag ? 1 : 0 } as any);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export function checkOverlayID(ui: MaplatUi, mapID: string) {
|
|
363
|
+
const swiper = ui.overlaySwiper;
|
|
364
|
+
const sliders = swiper.$el[0].querySelectorAll(".swiper-slide");
|
|
365
|
+
for (let i = 0; i < sliders.length; i++) {
|
|
366
|
+
const slider = sliders[i];
|
|
367
|
+
if (slider.getAttribute("data") === mapID) {
|
|
368
|
+
return true;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export function handleMarkerActionById(_ui: MaplatUi, markerId: string) {
|
|
375
|
+
console.log(`Open marker: ${markerId}`);
|
|
376
|
+
}
|
package/src/ui_utils.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export function resolveRelativeLink(
|
|
2
|
+
file: string,
|
|
3
|
+
fallbackPath: string | null
|
|
4
|
+
): string {
|
|
5
|
+
if (!fallbackPath) fallbackPath = ".";
|
|
6
|
+
return file.match(/\//) ? file : `${fallbackPath}/${file}`;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function ellips(mapDivDocument: HTMLElement) {
|
|
10
|
+
const omitMark = "…";
|
|
11
|
+
const omitLine = 2;
|
|
12
|
+
const stringSplit = function (element: HTMLElement) {
|
|
13
|
+
const splitArr = element.innerText.split("");
|
|
14
|
+
let joinString = "";
|
|
15
|
+
for (let i = 0; i < splitArr.length; i++) {
|
|
16
|
+
joinString += `<span>${splitArr[i]}</span>`;
|
|
17
|
+
}
|
|
18
|
+
joinString += `<span class="omit-mark">${omitMark}</span>`;
|
|
19
|
+
element.innerHTML = joinString;
|
|
20
|
+
};
|
|
21
|
+
const omitCheck = function (element: HTMLElement) {
|
|
22
|
+
const thisSpan = element.querySelectorAll("span");
|
|
23
|
+
const omitSpan = element.querySelector(".omit-mark") as HTMLElement;
|
|
24
|
+
let lineCount = 0;
|
|
25
|
+
let omitCount = 0;
|
|
26
|
+
|
|
27
|
+
if (omitLine <= 0) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
thisSpan[0].style.display = "";
|
|
32
|
+
for (let i = 1; i < thisSpan.length; i++) {
|
|
33
|
+
thisSpan[i].style.display = "none";
|
|
34
|
+
}
|
|
35
|
+
omitSpan.style.display = "";
|
|
36
|
+
let divHeight = element.offsetHeight;
|
|
37
|
+
let minimizeFont = false;
|
|
38
|
+
for (let i = 1; i < thisSpan.length - 1; i++) {
|
|
39
|
+
thisSpan[i].style.display = "";
|
|
40
|
+
if (element.offsetHeight > divHeight) {
|
|
41
|
+
if (!minimizeFont) {
|
|
42
|
+
minimizeFont = true;
|
|
43
|
+
element.classList.add("minimize");
|
|
44
|
+
} else {
|
|
45
|
+
divHeight = element.offsetHeight;
|
|
46
|
+
lineCount++;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (lineCount >= omitLine) {
|
|
50
|
+
omitCount = i - 2;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
if (i >= thisSpan.length - 2) {
|
|
54
|
+
omitSpan.style.display = "none";
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
for (let i = omitCount; i < thisSpan.length - 1; i++) {
|
|
59
|
+
thisSpan[i].style.display = "none";
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const swiperItems = mapDivDocument.querySelectorAll(".swiper-slide div");
|
|
63
|
+
for (let i = 0; i < swiperItems.length; i++) {
|
|
64
|
+
const swiperItem = swiperItems[i] as HTMLElement;
|
|
65
|
+
stringSplit(swiperItem);
|
|
66
|
+
omitCheck(swiperItem);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function isMaplatSource(source: unknown): source is {
|
|
71
|
+
setGPSMarkerAsync: () => unknown;
|
|
72
|
+
constructor: { isBasemap_?: boolean };
|
|
73
|
+
} {
|
|
74
|
+
return (
|
|
75
|
+
!!source &&
|
|
76
|
+
typeof (source as { setGPSMarkerAsync: unknown }).setGPSMarkerAsync ===
|
|
77
|
+
"function"
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function isBasemap(source: unknown): boolean {
|
|
82
|
+
if (!isMaplatSource(source)) return false;
|
|
83
|
+
if (source.constructor && source.constructor.isBasemap_ === false)
|
|
84
|
+
return false;
|
|
85
|
+
if (source.constructor && source.constructor.isBasemap_ === true) return true;
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|