@maplat/ui 0.10.6 → 0.11.1

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.
Files changed (176) hide show
  1. package/LICENSE +223 -223
  2. package/README.md +128 -91
  3. package/assets/locales/de/translation.json +71 -0
  4. package/{locales → assets/locales}/en/translation.json +70 -64
  5. package/{locales → assets/locales}/ja/translation.json +70 -64
  6. package/{locales → assets/locales}/ko/translation.json +71 -65
  7. package/assets/locales/vi/translation.json +71 -0
  8. package/{locales → assets/locales}/zh/translation.json +71 -65
  9. package/{locales → assets/locales}/zh-TW/translation.json +71 -65
  10. package/assets/parts/attr.png +0 -0
  11. package/assets/parts/border.png +0 -0
  12. package/assets/parts/compass.png +0 -0
  13. package/assets/parts/gps.png +0 -0
  14. package/assets/parts/help.png +0 -0
  15. package/assets/parts/hide_marker.png +0 -0
  16. package/assets/parts/home.png +0 -0
  17. package/assets/parts/marker_list.png +0 -0
  18. package/assets/parts/share.png +0 -0
  19. package/dist/absolute_url.d.ts +1 -0
  20. package/dist/assets/locales/de/translation.json +71 -0
  21. package/dist/assets/locales/en/translation.json +70 -64
  22. package/dist/assets/locales/ja/translation.json +70 -64
  23. package/dist/assets/locales/ko/translation.json +71 -65
  24. package/dist/assets/locales/vi/translation.json +71 -0
  25. package/dist/assets/locales/zh/translation.json +71 -65
  26. package/dist/assets/locales/zh-TW/translation.json +71 -65
  27. package/dist/contextmenu.d.ts +5 -0
  28. package/dist/function.d.ts +2 -0
  29. package/dist/icons.d.ts +7 -0
  30. package/dist/index.d.ts +65 -0
  31. package/dist/maplat-ui.es.js +33551 -0
  32. package/dist/maplat-ui.umd.js +4934 -0
  33. package/dist/maplat_control.d.ts +55 -0
  34. package/dist/pointer_images.d.ts +2 -0
  35. package/dist/swiper_ex.d.ts +2 -0
  36. package/dist/types.d.ts +185 -0
  37. package/dist/ui_init.d.ts +4 -0
  38. package/dist/ui_marker.d.ts +9 -0
  39. package/dist/ui_utils.d.ts +9 -0
  40. package/less/bootstrap.less +7010 -7010
  41. package/less/contextmenu.css +8 -0
  42. package/less/font-awesome.less +51 -31
  43. package/less/iziToast.less +1732 -1732
  44. package/less/maplat-specific.less +1038 -652
  45. package/less/swiper4.css +715 -0
  46. package/less/ui.less +11 -11
  47. package/less/ui_packed.less +10 -10
  48. package/package.json +80 -79
  49. package/src/{absolute_url.js → absolute_url.ts} +1 -1
  50. package/src/contextmenu/base.ts +170 -0
  51. package/src/contextmenu/constants.ts +66 -0
  52. package/src/contextmenu/cssVars.ts +13 -0
  53. package/src/contextmenu/helpers/dom.ts +295 -0
  54. package/src/contextmenu/helpers/mix.ts +120 -0
  55. package/src/contextmenu/html.ts +161 -0
  56. package/src/contextmenu/internal.ts +293 -0
  57. package/src/contextmenu.ts +40 -0
  58. package/src/function.ts +36 -0
  59. package/src/icons.ts +46 -0
  60. package/src/index.ts +521 -0
  61. package/src/maplat_control.ts +629 -0
  62. package/src/pointer_images.ts +101 -0
  63. package/src/{service-worker.js → service-worker/index.ts} +5 -6
  64. package/src/swiper_augment.d.ts +13 -0
  65. package/src/{swiper_ex.js → swiper_ex.ts} +14 -10
  66. package/src/types.d.ts +31 -0
  67. package/src/types.ts +202 -0
  68. package/src/ui_init.ts +1175 -0
  69. package/src/ui_marker.ts +376 -0
  70. package/src/ui_utils.ts +87 -0
  71. package/dist/assets/fonts/a8c0074cf70b152b56105e6c4b227bd8.woff +0 -0
  72. package/dist/assets/fonts/cfeff2e898a64ebe7e6b5ec078b174c3.woff +0 -0
  73. package/dist/assets/images/09c3ce5a86d600e24f8e85de3a019853.png +0 -0
  74. package/dist/assets/images/0beac2cb41dfab43ddfd9df80b32b85d.png +0 -0
  75. package/dist/assets/images/1354b4f40dd58bb0f2a4871cb4ff81d8.png +0 -0
  76. package/dist/assets/images/2a61e310e46b50b5f8ddd5e905ba9db9.png +0 -0
  77. package/dist/assets/images/3131423d782cd3ea89a81247065e7f9d.png +0 -0
  78. package/dist/assets/images/41b2cf0fa604d3f196ca52337d238219.jpg +0 -0
  79. package/dist/assets/images/558bc7e8b9b6c5f41a7141cddb8cdb5e.png +0 -0
  80. package/dist/assets/images/56f7003805ed02f8a21199947651db2e.png +0 -0
  81. package/dist/assets/images/5ba349e3596aca094c41c56966b45dc7.png +0 -0
  82. package/dist/assets/images/6111b8076a2cf81c73f0e46f41a3af60.png +0 -0
  83. package/dist/assets/images/6345ee67d554fbfbf484ba4035ad19d9.jpg +0 -0
  84. package/dist/assets/images/649fce122b354de2ac725ba5f2661955.png +0 -0
  85. package/dist/assets/images/6a580287dea82c2fb9b214321a375145.png +0 -0
  86. package/dist/assets/images/6c5dba7f7d76e74c3a8c7c5b1c3fc544.png +0 -0
  87. package/dist/assets/images/6e1f2f2f6fed3c5cddeb925e7ae75aba.png +0 -0
  88. package/dist/assets/images/799a0177b0dc540682fa4a2e349a8f4f.png +0 -0
  89. package/dist/assets/images/7bef6f357e921c43f4f800cfcb757872.png +0 -0
  90. package/dist/assets/images/7d9d643a903df6f57b8b7386316021e5.png +0 -0
  91. package/dist/assets/images/7df82bae917b68159f84998182f2fdc6.png +0 -0
  92. package/dist/assets/images/8e5d0335f6598b8d874ba23ea9fb295f.png +0 -0
  93. package/dist/assets/images/90c32e751366be22777f3fe40a53fe06.png +0 -0
  94. package/dist/assets/images/9247459937b9c882303962e42bd8d989.png +0 -0
  95. package/dist/assets/images/927c34e7b9b2f95c82ba477993117eaf.png +0 -0
  96. package/dist/assets/images/95e9ca8285131f8ccb6da5052093173c.png +0 -0
  97. package/dist/assets/images/9a243e0cb0fc43e2a016d5d3aaa330d5.png +0 -0
  98. package/dist/assets/images/9ac6d81f417d6a5626b7c8d5a087c32b.png +0 -0
  99. package/dist/assets/images/9d3a01c866095b8b3e8e63f9cf11dd51.png +0 -0
  100. package/dist/assets/images/9df733bcb29a746cb16b47eedea9fc3a.png +0 -0
  101. package/dist/assets/images/acc6eab0ba9c470ae20fb4b74135e865.png +0 -0
  102. package/dist/assets/images/b9ae27f0a01228380dff76a33b605707.jpg +0 -0
  103. package/dist/assets/images/ba48b220f61a6e1028f1854326f43acd.png +0 -0
  104. package/dist/assets/images/bf67cc860289b85c0402a4d4f890a3bd.png +0 -0
  105. package/dist/assets/images/c49f2344772e33256ba24d64b59b20d1.png +0 -0
  106. package/dist/assets/images/ca6b77b234b18e7bb9b1ccda774da286.png +0 -0
  107. package/dist/assets/images/cd213169df16398b0017450e31788d73.png +0 -0
  108. package/dist/assets/images/f101a0974972eeab41189185a5c5b225.png +0 -0
  109. package/dist/assets/images/f115726e6249018905cca51653e1262c.png +0 -0
  110. package/dist/assets/images/f7acb820d978ab2dd69e8bf695c574d1.png +0 -0
  111. package/dist/assets/images/ffea4dd10bf2506aa1e0cd4c61426b42.png +0 -0
  112. package/dist/assets/maplat.css +0 -19
  113. package/dist/assets/maplat.css.map +0 -1
  114. package/dist/assets/maplat.js +0 -3
  115. package/dist/assets/maplat.js.LICENSE.txt +0 -43
  116. package/dist/assets/maplat.js.map +0 -1
  117. package/dist/index.html +0 -125
  118. package/dist/service-worker.js +0 -3
  119. package/dist/service-worker.js.LICENSE.txt +0 -1
  120. package/dist/service-worker.js.map +0 -1
  121. package/fonts/clarenbd-webfont.woff +0 -0
  122. package/fonts/fontawesome-webfont.woff +0 -0
  123. package/legacy/bootstrap-native.js +0 -1935
  124. package/legacy/detect-element-resize.js +0 -153
  125. package/legacy/iziToast.js +0 -1301
  126. package/legacy/page.js +0 -1153
  127. package/legacy/qrcode.js +0 -616
  128. package/legacy/sprintf.js +0 -285
  129. package/less/font-face.less +0 -11
  130. package/less/font-face_packed.less +0 -11
  131. package/parts/attr.png +0 -0
  132. package/parts/blue_marker.png +0 -0
  133. package/parts/bluedot.png +0 -0
  134. package/parts/bluedot_small.png +0 -0
  135. package/parts/bluedot_transparent.png +0 -0
  136. package/parts/border.png +0 -0
  137. package/parts/compass.png +0 -0
  138. package/parts/defaultpin.png +0 -0
  139. package/parts/defaultpin_selected.png +0 -0
  140. package/parts/gps.png +0 -0
  141. package/parts/gsi.jpg +0 -0
  142. package/parts/gsi_ortho.jpg +0 -0
  143. package/parts/help.png +0 -0
  144. package/parts/hide_marker.png +0 -0
  145. package/parts/home.png +0 -0
  146. package/parts/osm.jpg +0 -0
  147. package/parts/red_marker.png +0 -0
  148. package/parts/redcircle.png +0 -0
  149. package/parts/share.png +0 -0
  150. package/src/contextmenu.js +0 -29
  151. package/src/freeze_locales.js +0 -337
  152. package/src/function.js +0 -22
  153. package/src/index.js +0 -1778
  154. package/src/index_packed.js +0 -8
  155. package/src/maplat_control.js +0 -808
  156. package/src/pointer_images.js +0 -81
  157. /package/{parts → assets/parts}/Maplat.png +0 -0
  158. /package/{parts → assets/parts}/all_right_reserved.png +0 -0
  159. /package/{parts → assets/parts}/basemap.png +0 -0
  160. /package/{parts → assets/parts}/cc0.png +0 -0
  161. /package/{parts → assets/parts}/cc_by-nc-nd.png +0 -0
  162. /package/{parts → assets/parts}/cc_by-nc-sa.png +0 -0
  163. /package/{parts → assets/parts}/cc_by-nc.png +0 -0
  164. /package/{parts → assets/parts}/cc_by-nd.png +0 -0
  165. /package/{parts → assets/parts}/cc_by-sa.png +0 -0
  166. /package/{parts → assets/parts}/cc_by.png +0 -0
  167. /package/{parts → assets/parts}/favicon.png +0 -0
  168. /package/{parts → assets/parts}/fullscreen.png +0 -0
  169. /package/{parts → assets/parts}/loading.png +0 -0
  170. /package/{parts → assets/parts}/loading_image.png +0 -0
  171. /package/{parts → assets/parts}/minus.png +0 -0
  172. /package/{parts → assets/parts}/no_image.png +0 -0
  173. /package/{parts → assets/parts}/overlay.png +0 -0
  174. /package/{parts → assets/parts}/pd.png +0 -0
  175. /package/{parts → assets/parts}/plus.png +0 -0
  176. /package/{parts → assets/parts}/slider.png +0 -0
@@ -0,0 +1,629 @@
1
+ import { Control, Rotate, Zoom as BaseZoom } from "ol/control";
2
+ import { CLASS_UNSELECTABLE, CLASS_CONTROL } from "ol/css";
3
+ import { MapEvent } from "ol";
4
+
5
+ import pointer from "./pointer_images";
6
+ import { createElement, MaplatApp } from "@maplat/core";
7
+ import { getIcon } from "./icons";
8
+ import type { MaplatUi } from "./index";
9
+ import type { ControlOptions } from "./types";
10
+
11
+ export let control_settings: Record<string, string> = {};
12
+ const delegator: { [key: string]: string } = {
13
+ compass: "compass.png",
14
+ border: "border.png",
15
+ attr: "attr.png",
16
+ gps: "gps.png",
17
+ zoom_plus: "plus.png",
18
+ zoom_minus: "minus.png",
19
+ help: "help.png",
20
+ home: "home.png",
21
+ hide_marker: "hide_marker.png",
22
+ marker_list: "marker_list.png",
23
+ share: "share.png",
24
+ slider_in_help: "slider.png",
25
+ favicon: "favicon.png"
26
+ };
27
+
28
+ function hexRgb(hex: string) {
29
+ const ret: { red: number; green: number; blue: number } = {
30
+ red: 0,
31
+ green: 0,
32
+ blue: 0
33
+ };
34
+ if (hex.match(/^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i)) {
35
+ ret.red = parseInt(RegExp.$1, 16);
36
+ ret.green = parseInt(RegExp.$2, 16);
37
+ ret.blue = parseInt(RegExp.$3, 16);
38
+ } else if (hex.match(/^#?([0-9A-F])([0-9A-F])([0-9A-F])$/i)) {
39
+ ret.red = parseInt(`${RegExp.$1}${RegExp.$1}`, 16);
40
+ ret.green = parseInt(`${RegExp.$2}${RegExp.$2}`, 16);
41
+ ret.blue = parseInt(`${RegExp.$3}${RegExp.$3}`, 16);
42
+ }
43
+ return ret;
44
+ }
45
+
46
+ export function setControlSettings(options: Record<string, string>) {
47
+ control_settings = options;
48
+ Object.keys(control_settings).forEach(key => {
49
+ if (delegator[key]) {
50
+ (pointer as Record<string, string>)[delegator[key]] =
51
+ control_settings[key];
52
+ }
53
+ });
54
+ }
55
+
56
+ export class SliderNew extends Control {
57
+ constructor(opt_options: ControlOptions) {
58
+ const options = opt_options ? opt_options : {};
59
+ const containerElement = document.createElement("input");
60
+ containerElement.type = "range";
61
+ containerElement.min = "0";
62
+ containerElement.max = "1";
63
+ const initialValue = options.initialValue || 0;
64
+ containerElement.value = `${1 - initialValue}`;
65
+ containerElement.step = "0.01";
66
+ const render = options.render
67
+ ? options.render
68
+ : function (mapEvent: MapEvent) {
69
+ if (!mapEvent.frameState) return;
70
+ };
71
+ super({
72
+ element: containerElement,
73
+ render
74
+ });
75
+ const className =
76
+ options.className !== undefined ? options.className : "ol-slidernew";
77
+ this.set("slidervalue", initialValue);
78
+
79
+ containerElement.title = options.tipLabel || "";
80
+ containerElement.className = `${className} ${CLASS_UNSELECTABLE} ${CLASS_CONTROL}`;
81
+ containerElement.addEventListener("click", ev => {
82
+ ev.stopPropagation();
83
+ });
84
+ containerElement.addEventListener("pointerdown", ev => {
85
+ ev.stopPropagation();
86
+ });
87
+ containerElement.addEventListener("pointerup", ev => {
88
+ ev.stopPropagation();
89
+ });
90
+
91
+ containerElement.addEventListener("input", _ev => {
92
+ this.set(
93
+ "slidervalue",
94
+ 1 - parseFloat((this.element as HTMLInputElement).value)
95
+ );
96
+ });
97
+
98
+ if (control_settings["slider_color"]) {
99
+ const rgb = hexRgb(control_settings["slider_color"]);
100
+ containerElement.classList.add("ol-slider-originalcolor");
101
+ const sheets = document.styleSheets;
102
+ const sheet = sheets[sheets.length - 1] as CSSStyleSheet;
103
+ try {
104
+ sheet.insertRule(
105
+ `.maplat.with-opacity .ol-slider-originalcolor.${className}::-webkit-slider-thumb {
106
+ background: rgba(${rgb.red},${rgb.green},${rgb.blue}, 0.5);
107
+ }`,
108
+ sheet.cssRules.length
109
+ );
110
+
111
+ sheet.insertRule(
112
+ `.maplat.with-opacity .ol-slider-originalcolor.${className}::-moz-range-thumb {
113
+ background: rgba(${rgb.red},${rgb.green},${rgb.blue}, 0.5);
114
+ }`,
115
+ sheet.cssRules.length
116
+ );
117
+
118
+ sheet.insertRule(
119
+ `.maplat.with-opacity .ol-slider-originalcolor.${className}[disabled]::-webkit-slider-thumb {
120
+ background: rgba(${rgb.red},${rgb.green},${rgb.blue}, 0.2);
121
+ }`,
122
+ sheet.cssRules.length
123
+ );
124
+
125
+ sheet.insertRule(
126
+ `.maplat.with-opacity .ol-slider-originalcolor.${className}[disabled]::-moz-range-thumb {
127
+ background: rgba(${rgb.red},${rgb.green},${rgb.blue}, 0.2);
128
+ }`,
129
+ sheet.cssRules.length
130
+ );
131
+
132
+ sheet.insertRule(
133
+ `.maplat.with-opacity .ol-slider-originalcolor.${className}:not([disabled])::-webkit-slider-thumb:hover {
134
+ background: rgba(${rgb.red},${rgb.green},${rgb.blue}, 0.7);
135
+ }`,
136
+ sheet.cssRules.length
137
+ );
138
+
139
+ sheet.insertRule(
140
+ `.maplat.with-opacity .ol-slider-originalcolor.${className}:not([disabled])::-moz-range-thumb:hover {
141
+ background: rgba(${rgb.red},${rgb.green},${rgb.blue}, 0.7);
142
+ }`,
143
+ sheet.cssRules.length
144
+ );
145
+ } catch (e) {
146
+ console.error(e);
147
+ }
148
+ }
149
+ }
150
+
151
+ setMap(map: import("ol").Map) {
152
+ super.setMap(map);
153
+ if (map) {
154
+ map.render();
155
+ }
156
+ }
157
+
158
+ setEnable(cond: boolean) {
159
+ const elem = this.element as HTMLInputElement;
160
+ if (cond) {
161
+ elem.disabled = false;
162
+ } else {
163
+ elem.disabled = true;
164
+ }
165
+ }
166
+
167
+ setValue(res: number) {
168
+ this.set("slidervalue", res);
169
+ (this.element as HTMLInputElement).value = (1 - res).toString();
170
+ }
171
+ }
172
+
173
+ export class CustomControl extends Control {
174
+ center_: import("ol/coordinate").Coordinate | undefined;
175
+ zoom_: number | undefined;
176
+ callResetNorth_: unknown;
177
+ lastRotation_: number = 0;
178
+ label_!: HTMLElement;
179
+ ui!: MaplatUi;
180
+ moveTo_: boolean = false;
181
+
182
+ constructor(optOptions: ControlOptions) {
183
+ const options: ControlOptions = optOptions || {};
184
+ const element = document.createElement("div");
185
+
186
+ super({
187
+ element,
188
+ target: options.target,
189
+ render: options.render
190
+ });
191
+
192
+ const button = document.createElement("button");
193
+ button.setAttribute("type", "button");
194
+ button.title = options.tipLabel || "";
195
+ const span = document.createElement("span");
196
+ span.innerHTML = options.character || "";
197
+ button.appendChild(span);
198
+ let timer: number | null | undefined | boolean;
199
+ let touchstart: boolean;
200
+
201
+ button.addEventListener("click", e => {
202
+ e.stopPropagation();
203
+ });
204
+ button.addEventListener(
205
+ "mouseup",
206
+ e => {
207
+ if (!touchstart) {
208
+ if (timer) {
209
+ if (options.long_callback) {
210
+ clearTimeout(timer as number);
211
+ }
212
+ timer = null;
213
+ if (options.callback) options.callback.apply(this);
214
+ }
215
+ }
216
+ e.stopPropagation();
217
+ },
218
+ false
219
+ );
220
+ button.addEventListener(
221
+ "mousemove",
222
+ e => {
223
+ e.stopPropagation();
224
+ },
225
+ false
226
+ );
227
+ button.addEventListener(
228
+ "mousedown",
229
+ e => {
230
+ if (!touchstart) {
231
+ if (options.long_callback) {
232
+ timer = window.setTimeout(() => {
233
+ timer = null;
234
+ if (options.long_callback) options.long_callback.apply(this);
235
+ }, 1500);
236
+ } else {
237
+ timer = true;
238
+ }
239
+ }
240
+ e.stopPropagation();
241
+ },
242
+ false
243
+ );
244
+ button.addEventListener(
245
+ "touchstart",
246
+ e => {
247
+ touchstart = true;
248
+ if (options.long_callback) {
249
+ timer = window.setTimeout(() => {
250
+ timer = null;
251
+ if (options.long_callback) options.long_callback.apply(this);
252
+ }, 1500);
253
+ } else {
254
+ timer = true;
255
+ }
256
+ e.stopPropagation();
257
+ },
258
+ false
259
+ );
260
+ button.addEventListener(
261
+ "touchend",
262
+ e => {
263
+ if (timer) {
264
+ if (options.long_callback) {
265
+ clearTimeout(timer as number);
266
+ }
267
+ timer = null;
268
+ if (options.callback) options.callback.apply(this);
269
+ }
270
+ e.stopPropagation();
271
+ },
272
+ false
273
+ );
274
+ button.addEventListener(
275
+ "mouseout",
276
+ e => {
277
+ if (options.long_callback && typeof timer === "number") {
278
+ clearTimeout(timer);
279
+ }
280
+ timer = null;
281
+ e.stopPropagation();
282
+ },
283
+ false
284
+ );
285
+ button.addEventListener(
286
+ "dblclick",
287
+ e => {
288
+ e.preventDefault();
289
+ },
290
+ false
291
+ );
292
+
293
+ element.className = `${options.cls} ol-unselectable ol-control`;
294
+ element.appendChild(button);
295
+ }
296
+ }
297
+
298
+ export class GoHome extends CustomControl {
299
+ constructor(optOptions: ControlOptions) {
300
+ const options: ControlOptions = optOptions || {};
301
+ options.character = control_settings["home"]
302
+ ? `<img src="${control_settings["home"]}">`
303
+ : getIcon("house", "far fa-lg");
304
+ options.cls = "home";
305
+ options.callback = function (this: Control) {
306
+ const map = this.getMap();
307
+ if (map) {
308
+ const source = (
309
+ map.getLayers().item(0) as import("ol/layer").Layer
310
+ ).getSource();
311
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
312
+ if (source && (source as any).goHome) {
313
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
314
+ (source as any).goHome();
315
+ }
316
+ }
317
+ };
318
+ super(options);
319
+ if (control_settings["home"]) {
320
+ const button = this.element.querySelector("button");
321
+ if (button) button.style.backgroundColor = "rgba(0,0,0,0)";
322
+ }
323
+ }
324
+ }
325
+
326
+ export class SetGPS extends CustomControl {
327
+ constructor(optOptions: ControlOptions) {
328
+ const options: ControlOptions = optOptions || {};
329
+ options.character = control_settings["gps"]
330
+ ? `<img src="${control_settings["gps"]}">`
331
+ : getIcon("location-crosshairs", "far fa-lg");
332
+ options.cls = "gps";
333
+ options.render = function (this: SetGPS, mapEvent: MapEvent) {
334
+ const frameState = mapEvent.frameState;
335
+ if (!frameState) {
336
+ return;
337
+ }
338
+ const core = this.ui!.core as MaplatApp;
339
+ if (core && core.getGPSEnabled) {
340
+ const enabled = core.getGPSEnabled();
341
+ const isDisabled = this.element.classList.contains("disable");
342
+
343
+ if (enabled && isDisabled) {
344
+ this.element.classList.remove("disable");
345
+ } else if (!enabled && !isDisabled) {
346
+ this.element.classList.add("disable");
347
+ }
348
+ }
349
+ };
350
+ options.callback = function (this: Control) {
351
+ const self = this as SetGPS;
352
+ const core = self.ui.core as MaplatApp;
353
+
354
+ const currentlyEnabled = core.getGPSEnabled();
355
+
356
+ if (core.alwaysGpsOn) {
357
+ core.handleGPS(true);
358
+ if (self.ui.lastGPSError === "gps_out") {
359
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
360
+ self.ui.core!.dispatchEvent(new CustomEvent("outOfMap") as any);
361
+ }
362
+ } else {
363
+ core.handleGPS(!currentlyEnabled);
364
+ }
365
+ };
366
+
367
+ super(options);
368
+
369
+ this.ui = options.ui!;
370
+ this.moveTo_ = false;
371
+
372
+ if (control_settings["gps"]) {
373
+ const button = this.element.querySelector("button");
374
+ if (button) button.style.backgroundColor = "rgba(0,0,0,0)";
375
+ }
376
+ }
377
+ }
378
+
379
+ export class CompassRotate extends Rotate {
380
+ center_?: import("ol/coordinate").Coordinate;
381
+ zoom_?: number;
382
+ customLabel_: HTMLElement;
383
+ lastRotation_: number = 0;
384
+
385
+ constructor(optOptions: ControlOptions) {
386
+ const options: ControlOptions = optOptions || {};
387
+ options.autoHide = false;
388
+ const span = document.createElement("span");
389
+ span.innerHTML = control_settings["compass"]
390
+ ? `<img src="${control_settings["compass"]}">`
391
+ : getIcon("compass", "far fa-lg ol-compass-fa");
392
+ options.label = span;
393
+ options.render = function (this: CompassRotate, mapEvent: MapEvent) {
394
+ const frameState = mapEvent.frameState;
395
+
396
+ if (!frameState) {
397
+ return;
398
+ }
399
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
400
+ const view = (this.getMap() as any).getView();
401
+ const rotation = frameState.viewState.rotation;
402
+ const center = view.getCenter();
403
+ const zoom = view.getDecimalZoom ? view.getDecimalZoom() : view.getZoom();
404
+ if (
405
+ rotation != this.lastRotation_ ||
406
+ (center &&
407
+ this.center_ &&
408
+ (center[0] != this.center_[0] || center[1] != this.center_[1])) ||
409
+ zoom != this.zoom_
410
+ ) {
411
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
412
+ if (!(this.getMap() as any).northUp) {
413
+ const contains = this.element.classList.contains("disable");
414
+ if (!contains && rotation === 0) {
415
+ this.element.classList.add("disable");
416
+ } else if (contains && rotation !== 0) {
417
+ this.element.classList.remove("disable");
418
+ }
419
+ }
420
+
421
+ const layer = this.getMap()!.getLayers().item(0);
422
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
423
+ const source = (layer as any).getSource
424
+ ? // eslint-disable-next-line @typescript-eslint/no-explicit-any
425
+ (layer as any).getSource()
426
+ : // eslint-disable-next-line @typescript-eslint/no-explicit-any
427
+ (layer as any).getLayers().item(0).getSource();
428
+ if (!source) {
429
+ const transform = "rotate(0rad)";
430
+ this.customLabel_.style.transform = transform;
431
+
432
+ return;
433
+ }
434
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
435
+ if ((source as any).viewpoint2MercsAsync) {
436
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
437
+ (source as any).viewpoint2MercsAsync().then((mercs: any) => {
438
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
439
+ const direction = (source as any).mercs2MercViewpoint(mercs)[2];
440
+ const transform = `rotate(${direction}rad)`;
441
+ this.customLabel_.style.transform = transform;
442
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
443
+ if ((this.getMap() as any).northUp) {
444
+ const contains = this.element.classList.contains("disable");
445
+ if (!contains && Math.abs(direction) < 0.1) {
446
+ this.element.classList.add("disable");
447
+ } else if (contains && Math.abs(direction) >= 0.1) {
448
+ this.element.classList.remove("disable");
449
+ }
450
+ }
451
+ });
452
+ }
453
+ }
454
+ this.lastRotation_ = rotation;
455
+ this.center_ = center;
456
+ this.zoom_ = zoom;
457
+ };
458
+ super(options);
459
+ this.customLabel_ = span;
460
+ }
461
+ }
462
+
463
+ export class Share extends CustomControl {
464
+ constructor(optOptions: ControlOptions) {
465
+ const options: ControlOptions = optOptions || {};
466
+ options.character = control_settings["share"]
467
+ ? `<img src="${control_settings["share"]}">`
468
+ : getIcon("share-from-square", "far fa-lg");
469
+ options.cls = "ol-share";
470
+ options.callback = function (this: Control) {
471
+ const map = this.getMap();
472
+ if (map)
473
+ map.dispatchEvent(
474
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
475
+ new MapEvent("click_control", map, { control: "share" } as any)
476
+ );
477
+ };
478
+
479
+ super(options);
480
+ if (control_settings["share"]) {
481
+ const button = this.element.querySelector("button");
482
+ if (button) button.style.backgroundColor = "rgba(0,0,0,0)";
483
+ }
484
+ }
485
+ }
486
+
487
+ export class Border extends CustomControl {
488
+ constructor(optOptions: ControlOptions) {
489
+ const options: ControlOptions = optOptions || {};
490
+
491
+ options.character = control_settings["border"]
492
+ ? `<img src="${control_settings["border"]}">`
493
+ : getIcon("layer-group", "far fa-lg");
494
+ options.cls = "ol-border";
495
+ options.callback = function (this: Control) {
496
+ const map = this.getMap();
497
+ if (map)
498
+ map.dispatchEvent(
499
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
500
+ new MapEvent("click_control", map, { control: "border" } as any)
501
+ );
502
+ };
503
+
504
+ super(options);
505
+ if (control_settings["border"]) {
506
+ const button = this.element.querySelector("button");
507
+ if (button) button.style.backgroundColor = "rgba(0,0,0,0)";
508
+ }
509
+ }
510
+ }
511
+
512
+ export class Maplat extends CustomControl {
513
+ constructor(optOptions: ControlOptions) {
514
+ const options: ControlOptions = optOptions || {};
515
+ options.character = control_settings["help"]
516
+ ? `<img src="${control_settings["help"]}">`
517
+ : getIcon("circle-question", "far fa-lg");
518
+ options.cls = "ol-maplat";
519
+ options.callback = function (this: Control) {
520
+ const map = this.getMap();
521
+ if (map)
522
+ map.dispatchEvent(
523
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
524
+ new MapEvent("click_control", map, { control: "help" } as any)
525
+ );
526
+ };
527
+
528
+ super(options);
529
+ if (control_settings["help"]) {
530
+ const button = this.element.querySelector("button");
531
+ if (button) button.style.backgroundColor = "rgba(0,0,0,0)";
532
+ }
533
+ }
534
+ }
535
+
536
+ export class Copyright extends CustomControl {
537
+ constructor(optOptions: ControlOptions) {
538
+ const options: ControlOptions = optOptions || {};
539
+ options.character = control_settings["attr"]
540
+ ? `<img src="${control_settings["attr"]}">`
541
+ : getIcon("circle-info", "far fa-lg");
542
+ options.cls = "ol-copyright";
543
+ options.callback = function (this: Control) {
544
+ const map = this.getMap();
545
+ if (map)
546
+ map.dispatchEvent(
547
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
548
+ new MapEvent("click_control", map, { control: "copyright" } as any)
549
+ );
550
+ };
551
+
552
+ super(options);
553
+ if (control_settings["attr"]) {
554
+ const button = this.element.querySelector("button");
555
+ if (button) button.style.backgroundColor = "rgba(0,0,0,0)";
556
+ }
557
+ }
558
+ }
559
+
560
+ export class HideMarker extends CustomControl {
561
+ constructor(optOptions: ControlOptions) {
562
+ const options: ControlOptions = optOptions || {};
563
+ options.character = control_settings["hide_marker"]
564
+ ? `<img src="${control_settings["hide_marker"]}">`
565
+ : getIcon("map-pin", "far fa-lg");
566
+ options.cls = "ol-hide-marker";
567
+ options.callback = function (this: Control) {
568
+ const map = this.getMap();
569
+ if (map)
570
+ map.dispatchEvent(
571
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
572
+ new MapEvent("click_control", map, { control: "hideMarker" } as any)
573
+ );
574
+ };
575
+
576
+ super(options);
577
+ if (control_settings["hide_marker"]) {
578
+ const button = this.element.querySelector("button");
579
+ if (button) button.style.backgroundColor = "rgba(0,0,0,0)";
580
+ }
581
+ }
582
+ }
583
+
584
+ export class MarkerList extends CustomControl {
585
+ constructor(optOptions: ControlOptions) {
586
+ const options: ControlOptions = optOptions || {};
587
+ options.character = control_settings["marker_list"]
588
+ ? `<img src="${control_settings["marker_list"]}">`
589
+ : getIcon("list", "far fa-lg");
590
+ options.cls = "ol-marker-list";
591
+ options.callback = function (this: Control) {
592
+ const map = this.getMap();
593
+ if (map)
594
+ map.dispatchEvent(
595
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
596
+ new MapEvent("click_control", map, { control: "markerList" } as any)
597
+ );
598
+ };
599
+
600
+ super(options);
601
+ if (control_settings["marker_list"]) {
602
+ const button = this.element.querySelector("button");
603
+ if (button) button.style.backgroundColor = "rgba(0,0,0,0)";
604
+ }
605
+ }
606
+ }
607
+
608
+ export class Zoom extends BaseZoom {
609
+ constructor(options: ControlOptions = {}) {
610
+ if (control_settings["zoom_plus"]) {
611
+ options.zoomInLabel = createElement(
612
+ `<img src="${control_settings["zoom_plus"]}">`
613
+ )[0] as HTMLElement;
614
+ }
615
+ if (control_settings["zoom_minus"]) {
616
+ options.zoomOutLabel = createElement(
617
+ `<img src="${control_settings["zoom_minus"]}">`
618
+ )[0] as HTMLElement;
619
+ }
620
+
621
+ super(options);
622
+ if (control_settings["compass"]) {
623
+ const buttons = this.element.querySelectorAll("button");
624
+ buttons.forEach(button => {
625
+ button.style.backgroundColor = "rgba(0,0,0,0)";
626
+ });
627
+ }
628
+ }
629
+ }