@geolonia/maps-core 0.0.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.
package/dist/index.cjs ADDED
@@ -0,0 +1,1881 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __typeError = (msg) => {
9
+ throw TypeError(msg);
10
+ };
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
33
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
34
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
35
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
36
+
37
+ // src/index.ts
38
+ var index_exports = {};
39
+ __export(index_exports, {
40
+ CustomAttributionControl: () => attribution_default,
41
+ GeoloniaControl: () => GeoloniaControl,
42
+ GeoloniaMap: () => GeoloniaMap,
43
+ GeoloniaMarker: () => GeoloniaMarker,
44
+ SimpleStyle: () => SimpleStyle,
45
+ SimpleStyleVector: () => simplestyle_vector_default,
46
+ coreVersion: () => VERSION,
47
+ getLang: () => getLang,
48
+ getStyle: () => getStyle,
49
+ isGeoloniaTilesHost: () => isGeoloniaTilesHost,
50
+ keyring: () => keyring
51
+ });
52
+ module.exports = __toCommonJS(index_exports);
53
+
54
+ // node_modules/@mapbox/point-geometry/index.js
55
+ function Point(x, y) {
56
+ this.x = x;
57
+ this.y = y;
58
+ }
59
+ Point.prototype = {
60
+ /**
61
+ * Clone this point, returning a new point that can be modified
62
+ * without affecting the old one.
63
+ * @return {Point} the clone
64
+ */
65
+ clone() {
66
+ return new Point(this.x, this.y);
67
+ },
68
+ /**
69
+ * Add this point's x & y coordinates to another point,
70
+ * yielding a new point.
71
+ * @param {Point} p the other point
72
+ * @return {Point} output point
73
+ */
74
+ add(p) {
75
+ return this.clone()._add(p);
76
+ },
77
+ /**
78
+ * Subtract this point's x & y coordinates to from point,
79
+ * yielding a new point.
80
+ * @param {Point} p the other point
81
+ * @return {Point} output point
82
+ */
83
+ sub(p) {
84
+ return this.clone()._sub(p);
85
+ },
86
+ /**
87
+ * Multiply this point's x & y coordinates by point,
88
+ * yielding a new point.
89
+ * @param {Point} p the other point
90
+ * @return {Point} output point
91
+ */
92
+ multByPoint(p) {
93
+ return this.clone()._multByPoint(p);
94
+ },
95
+ /**
96
+ * Divide this point's x & y coordinates by point,
97
+ * yielding a new point.
98
+ * @param {Point} p the other point
99
+ * @return {Point} output point
100
+ */
101
+ divByPoint(p) {
102
+ return this.clone()._divByPoint(p);
103
+ },
104
+ /**
105
+ * Multiply this point's x & y coordinates by a factor,
106
+ * yielding a new point.
107
+ * @param {number} k factor
108
+ * @return {Point} output point
109
+ */
110
+ mult(k) {
111
+ return this.clone()._mult(k);
112
+ },
113
+ /**
114
+ * Divide this point's x & y coordinates by a factor,
115
+ * yielding a new point.
116
+ * @param {number} k factor
117
+ * @return {Point} output point
118
+ */
119
+ div(k) {
120
+ return this.clone()._div(k);
121
+ },
122
+ /**
123
+ * Rotate this point around the 0, 0 origin by an angle a,
124
+ * given in radians
125
+ * @param {number} a angle to rotate around, in radians
126
+ * @return {Point} output point
127
+ */
128
+ rotate(a) {
129
+ return this.clone()._rotate(a);
130
+ },
131
+ /**
132
+ * Rotate this point around p point by an angle a,
133
+ * given in radians
134
+ * @param {number} a angle to rotate around, in radians
135
+ * @param {Point} p Point to rotate around
136
+ * @return {Point} output point
137
+ */
138
+ rotateAround(a, p) {
139
+ return this.clone()._rotateAround(a, p);
140
+ },
141
+ /**
142
+ * Multiply this point by a 4x1 transformation matrix
143
+ * @param {[number, number, number, number]} m transformation matrix
144
+ * @return {Point} output point
145
+ */
146
+ matMult(m) {
147
+ return this.clone()._matMult(m);
148
+ },
149
+ /**
150
+ * Calculate this point but as a unit vector from 0, 0, meaning
151
+ * that the distance from the resulting point to the 0, 0
152
+ * coordinate will be equal to 1 and the angle from the resulting
153
+ * point to the 0, 0 coordinate will be the same as before.
154
+ * @return {Point} unit vector point
155
+ */
156
+ unit() {
157
+ return this.clone()._unit();
158
+ },
159
+ /**
160
+ * Compute a perpendicular point, where the new y coordinate
161
+ * is the old x coordinate and the new x coordinate is the old y
162
+ * coordinate multiplied by -1
163
+ * @return {Point} perpendicular point
164
+ */
165
+ perp() {
166
+ return this.clone()._perp();
167
+ },
168
+ /**
169
+ * Return a version of this point with the x & y coordinates
170
+ * rounded to integers.
171
+ * @return {Point} rounded point
172
+ */
173
+ round() {
174
+ return this.clone()._round();
175
+ },
176
+ /**
177
+ * Return the magnitude of this point: this is the Euclidean
178
+ * distance from the 0, 0 coordinate to this point's x and y
179
+ * coordinates.
180
+ * @return {number} magnitude
181
+ */
182
+ mag() {
183
+ return Math.sqrt(this.x * this.x + this.y * this.y);
184
+ },
185
+ /**
186
+ * Judge whether this point is equal to another point, returning
187
+ * true or false.
188
+ * @param {Point} other the other point
189
+ * @return {boolean} whether the points are equal
190
+ */
191
+ equals(other) {
192
+ return this.x === other.x && this.y === other.y;
193
+ },
194
+ /**
195
+ * Calculate the distance from this point to another point
196
+ * @param {Point} p the other point
197
+ * @return {number} distance
198
+ */
199
+ dist(p) {
200
+ return Math.sqrt(this.distSqr(p));
201
+ },
202
+ /**
203
+ * Calculate the distance from this point to another point,
204
+ * without the square root step. Useful if you're comparing
205
+ * relative distances.
206
+ * @param {Point} p the other point
207
+ * @return {number} distance
208
+ */
209
+ distSqr(p) {
210
+ const dx = p.x - this.x, dy = p.y - this.y;
211
+ return dx * dx + dy * dy;
212
+ },
213
+ /**
214
+ * Get the angle from the 0, 0 coordinate to this point, in radians
215
+ * coordinates.
216
+ * @return {number} angle
217
+ */
218
+ angle() {
219
+ return Math.atan2(this.y, this.x);
220
+ },
221
+ /**
222
+ * Get the angle from this point to another point, in radians
223
+ * @param {Point} b the other point
224
+ * @return {number} angle
225
+ */
226
+ angleTo(b) {
227
+ return Math.atan2(this.y - b.y, this.x - b.x);
228
+ },
229
+ /**
230
+ * Get the angle between this point and another point, in radians
231
+ * @param {Point} b the other point
232
+ * @return {number} angle
233
+ */
234
+ angleWith(b) {
235
+ return this.angleWithSep(b.x, b.y);
236
+ },
237
+ /**
238
+ * Find the angle of the two vectors, solving the formula for
239
+ * the cross product a x b = |a||b|sin(θ) for θ.
240
+ * @param {number} x the x-coordinate
241
+ * @param {number} y the y-coordinate
242
+ * @return {number} the angle in radians
243
+ */
244
+ angleWithSep(x, y) {
245
+ return Math.atan2(
246
+ this.x * y - this.y * x,
247
+ this.x * x + this.y * y
248
+ );
249
+ },
250
+ /** @param {[number, number, number, number]} m */
251
+ _matMult(m) {
252
+ const x = m[0] * this.x + m[1] * this.y, y = m[2] * this.x + m[3] * this.y;
253
+ this.x = x;
254
+ this.y = y;
255
+ return this;
256
+ },
257
+ /** @param {Point} p */
258
+ _add(p) {
259
+ this.x += p.x;
260
+ this.y += p.y;
261
+ return this;
262
+ },
263
+ /** @param {Point} p */
264
+ _sub(p) {
265
+ this.x -= p.x;
266
+ this.y -= p.y;
267
+ return this;
268
+ },
269
+ /** @param {number} k */
270
+ _mult(k) {
271
+ this.x *= k;
272
+ this.y *= k;
273
+ return this;
274
+ },
275
+ /** @param {number} k */
276
+ _div(k) {
277
+ this.x /= k;
278
+ this.y /= k;
279
+ return this;
280
+ },
281
+ /** @param {Point} p */
282
+ _multByPoint(p) {
283
+ this.x *= p.x;
284
+ this.y *= p.y;
285
+ return this;
286
+ },
287
+ /** @param {Point} p */
288
+ _divByPoint(p) {
289
+ this.x /= p.x;
290
+ this.y /= p.y;
291
+ return this;
292
+ },
293
+ _unit() {
294
+ this._div(this.mag());
295
+ return this;
296
+ },
297
+ _perp() {
298
+ const y = this.y;
299
+ this.y = this.x;
300
+ this.x = -y;
301
+ return this;
302
+ },
303
+ /** @param {number} angle */
304
+ _rotate(angle) {
305
+ const cos = Math.cos(angle), sin = Math.sin(angle), x = cos * this.x - sin * this.y, y = sin * this.x + cos * this.y;
306
+ this.x = x;
307
+ this.y = y;
308
+ return this;
309
+ },
310
+ /**
311
+ * @param {number} angle
312
+ * @param {Point} p
313
+ */
314
+ _rotateAround(angle, p) {
315
+ const cos = Math.cos(angle), sin = Math.sin(angle), x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y), y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y);
316
+ this.x = x;
317
+ this.y = y;
318
+ return this;
319
+ },
320
+ _round() {
321
+ this.x = Math.round(this.x);
322
+ this.y = Math.round(this.y);
323
+ return this;
324
+ },
325
+ constructor: Point
326
+ };
327
+ Point.convert = function(p) {
328
+ if (p instanceof Point) {
329
+ return (
330
+ /** @type {Point} */
331
+ p
332
+ );
333
+ }
334
+ if (Array.isArray(p)) {
335
+ return new Point(+p[0], +p[1]);
336
+ }
337
+ if (p.x !== void 0 && p.y !== void 0) {
338
+ return new Point(+p.x, +p.y);
339
+ }
340
+ throw new Error("Expected [x, y] or {x, y} point format");
341
+ };
342
+
343
+ // src/lib/maplibre-util.ts
344
+ var _docStyle, _userSelect, _selectProp, _transformProp;
345
+ var _DOM = class _DOM {
346
+ static testProp(props) {
347
+ if (!__privateGet(_DOM, _docStyle)) return props[0];
348
+ for (let i = 0; i < props.length; i++) {
349
+ if (props[i] in __privateGet(_DOM, _docStyle)) {
350
+ return props[i];
351
+ }
352
+ }
353
+ return props[0];
354
+ }
355
+ static create(tagName, className, container) {
356
+ const el = window.document.createElement(tagName);
357
+ if (className !== void 0) el.className = className;
358
+ if (container) container.appendChild(el);
359
+ return el;
360
+ }
361
+ static createNS(namespaceURI, tagName) {
362
+ return window.document.createElementNS(namespaceURI, tagName);
363
+ }
364
+ static disableDrag() {
365
+ if (__privateGet(_DOM, _docStyle) && __privateGet(_DOM, _selectProp)) {
366
+ __privateSet(_DOM, _userSelect, __privateGet(_DOM, _docStyle)[__privateGet(_DOM, _selectProp)]);
367
+ __privateGet(_DOM, _docStyle)[__privateGet(_DOM, _selectProp)] = "none";
368
+ }
369
+ }
370
+ static enableDrag() {
371
+ if (__privateGet(_DOM, _docStyle) && __privateGet(_DOM, _selectProp)) {
372
+ __privateGet(_DOM, _docStyle)[__privateGet(_DOM, _selectProp)] = __privateGet(_DOM, _userSelect) ?? "";
373
+ }
374
+ }
375
+ static setTransform(el, value) {
376
+ el.style[__privateGet(_DOM, _transformProp)] = value;
377
+ }
378
+ static addEventListener(target, type, callback, options) {
379
+ if ("passive" in options) {
380
+ target.addEventListener(type, callback, options);
381
+ } else {
382
+ target.addEventListener(type, callback, options.capture);
383
+ }
384
+ }
385
+ static removeEventListener(target, type, callback, options) {
386
+ if ("passive" in options) {
387
+ target.removeEventListener(type, callback, options);
388
+ } else {
389
+ target.removeEventListener(type, callback, options.capture);
390
+ }
391
+ }
392
+ static mousePos(el, e) {
393
+ const rect = el.getBoundingClientRect();
394
+ return new Point(
395
+ e.clientX - rect.left - el.clientLeft,
396
+ e.clientY - rect.top - el.clientTop
397
+ );
398
+ }
399
+ static touchPos(el, touches) {
400
+ const rect = el.getBoundingClientRect();
401
+ const points = [];
402
+ for (let i = 0; i < touches.length; i++) {
403
+ points.push(
404
+ new Point(
405
+ touches[i].clientX - rect.left - el.clientLeft,
406
+ touches[i].clientY - rect.top - el.clientTop
407
+ )
408
+ );
409
+ }
410
+ return points;
411
+ }
412
+ static mouseButton(e) {
413
+ return e.button;
414
+ }
415
+ static remove(node) {
416
+ if (node.parentNode) {
417
+ node.parentNode.removeChild(node);
418
+ }
419
+ }
420
+ };
421
+ _docStyle = new WeakMap();
422
+ _userSelect = new WeakMap();
423
+ _selectProp = new WeakMap();
424
+ _transformProp = new WeakMap();
425
+ __privateAdd(_DOM, _docStyle, typeof window !== "undefined" && window.document && window.document.documentElement.style);
426
+ __privateAdd(_DOM, _userSelect);
427
+ __privateAdd(_DOM, _selectProp, _DOM.testProp([
428
+ "userSelect",
429
+ "MozUserSelect",
430
+ "WebkitUserSelect",
431
+ "msUserSelect"
432
+ ]));
433
+ __privateAdd(_DOM, _transformProp, _DOM.testProp([
434
+ "transform",
435
+ "WebkitTransform"
436
+ ]));
437
+ var DOM = _DOM;
438
+ function bindAll(fns, context) {
439
+ for (const fn of fns) {
440
+ if (typeof context[fn] === "function") {
441
+ context[fn] = context[fn].bind(
442
+ context
443
+ );
444
+ }
445
+ }
446
+ }
447
+
448
+ // src/lib/controls/attribution.ts
449
+ var ATTRIBUTION_CSS = `
450
+ .maplibregl-ctrl {
451
+ font: 12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;
452
+ clear: both;
453
+ pointer-events: auto;
454
+ transform: translate(0);
455
+ }
456
+ .maplibregl-ctrl-attrib-button:focus,.maplibregl-ctrl-group button:focus {
457
+ box-shadow: 0 0 2px 2px #0096ff
458
+ }
459
+ .maplibregl-ctrl.maplibregl-ctrl-attrib {
460
+ background-color: hsla(0,0%,100%,.5);
461
+ margin: 0;
462
+ padding: 0 5px
463
+ }
464
+ @media screen {
465
+ .maplibregl-ctrl-attrib.maplibregl-compact {
466
+ background-color: #fff;
467
+ border-radius: 12px;
468
+ box-sizing: content-box;
469
+ min-height: 20px;
470
+ padding: 2px 24px 2px 0;
471
+ position: relative;
472
+ margin: 10px 10px 10px auto;
473
+ width: 0;
474
+ }
475
+ .maplibregl-ctrl-attrib.maplibregl-compact-show {
476
+ padding: 2px 28px 2px 8px;
477
+ visibility: visible;
478
+ width: auto;
479
+ }
480
+ .maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact-show,
481
+ .maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact-show {
482
+ border-radius: 12px;
483
+ padding: 2px 8px 2px 28px
484
+ }
485
+ .maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-inner {
486
+ display: none
487
+ }
488
+ .maplibregl-ctrl-attrib-button {
489
+ background-color: hsla(0,0%,100%,.5);
490
+ background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='24' height='24' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E");
491
+ border: 0;
492
+ border-radius: 12px;
493
+ box-sizing: border-box;
494
+ cursor: pointer;
495
+ display: none;
496
+ height: 24px;
497
+ outline: none;
498
+ position: absolute;
499
+ right: 0;
500
+ top: 0;
501
+ width: 24px
502
+ }
503
+ .maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button {
504
+ appearance: none;
505
+ list-style: none
506
+ }
507
+ .maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button::-webkit-details-marker {
508
+ display: none
509
+ }
510
+ .maplibregl-ctrl-bottom-left .maplibregl-ctrl-attrib-button,
511
+ .maplibregl-ctrl-top-left .maplibregl-ctrl-attrib-button {
512
+ left: 0
513
+ }
514
+ .maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button,
515
+ .maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner {
516
+ display: block
517
+ }
518
+ .maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-button {
519
+ background-color: rgb(0 0 0/5%)
520
+ }
521
+ .maplibregl-ctrl-bottom-right>.maplibregl-ctrl-attrib.maplibregl-compact:after {
522
+ bottom: 0; right: 0
523
+ }
524
+ .maplibregl-ctrl-top-right>.maplibregl-ctrl-attrib.maplibregl-compact:after {
525
+ right: 0; top: 0
526
+ }
527
+ .maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact:after {
528
+ left: 0; top: 0
529
+ }
530
+ .maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact:after {
531
+ bottom: 0; left: 0
532
+ }
533
+ }
534
+ @media screen and (-ms-high-contrast:active) {
535
+ .maplibregl-ctrl-attrib.maplibregl-compact:after {
536
+ background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='24' height='24' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd' fill='%23fff'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")
537
+ }
538
+ }
539
+ @media screen and (-ms-high-contrast:black-on-white) {
540
+ .maplibregl-ctrl-attrib.maplibregl-compact:after {
541
+ background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='24' height='24' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")
542
+ }
543
+ }
544
+ @media print {
545
+ .maplibregl-ctrl-attrib-button {
546
+ display: none !important;
547
+ }
548
+ }
549
+ .maplibregl-ctrl-attrib a {
550
+ color: rgba(0,0,0,.75);
551
+ text-decoration: none;
552
+ white-space: nowrap;
553
+ }
554
+ .maplibregl-ctrl-attrib a:hover {
555
+ color: inherit;
556
+ text-decoration: underline
557
+ }
558
+ .maplibregl-attrib-empty {
559
+ display: none
560
+ }
561
+ `;
562
+ var CustomAttributionControl = class {
563
+ constructor(options = {}) {
564
+ this._editLink = null;
565
+ this.options = options;
566
+ bindAll(
567
+ [
568
+ "_toggleAttribution",
569
+ "_updateData",
570
+ "_updateCompact",
571
+ "_updateCompactMinimize"
572
+ ],
573
+ this
574
+ );
575
+ }
576
+ getDefaultPosition() {
577
+ return "bottom-right";
578
+ }
579
+ onAdd(map) {
580
+ this._map = map;
581
+ this._compact = this.options.compact;
582
+ this._container = DOM.create("div");
583
+ const shadow = this._container.attachShadow({ mode: "open" });
584
+ this._shadowContainer = DOM.create(
585
+ "details",
586
+ "maplibregl-ctrl maplibregl-ctrl-attrib"
587
+ );
588
+ this._compactButton = DOM.create(
589
+ "summary",
590
+ "maplibregl-ctrl-attrib-button",
591
+ this._shadowContainer
592
+ );
593
+ this._compactButton.addEventListener("click", this._toggleAttribution);
594
+ this._setElementTitle(this._compactButton, "ToggleAttribution");
595
+ this._innerContainer = DOM.create(
596
+ "div",
597
+ "maplibregl-ctrl-attrib-inner",
598
+ this._shadowContainer
599
+ );
600
+ const style = document.createElement("style");
601
+ style.textContent = ATTRIBUTION_CSS;
602
+ this._updateAttributions();
603
+ this._updateCompact();
604
+ this._map.on("styledata", this._updateData);
605
+ this._map.on("sourcedata", this._updateData);
606
+ this._map.on("terrain", this._updateData);
607
+ this._map.on("resize", this._updateCompact);
608
+ this._map.on("drag", this._updateCompactMinimize);
609
+ shadow.appendChild(style);
610
+ shadow.appendChild(this._shadowContainer);
611
+ this.printQuery = window.matchMedia("print");
612
+ this.onMediaPrintChange = (e) => {
613
+ if (e.matches) {
614
+ this._shadowContainer.setAttribute("open", "");
615
+ this._shadowContainer.classList.remove("maplibregl-compact-show");
616
+ }
617
+ };
618
+ this.printQuery.addEventListener("change", this.onMediaPrintChange);
619
+ return this._container;
620
+ }
621
+ onRemove() {
622
+ if (this._container) {
623
+ DOM.remove(this._container);
624
+ }
625
+ if (this._map) {
626
+ this._map.off("styledata", this._updateData);
627
+ this._map.off("sourcedata", this._updateData);
628
+ this._map.off("terrain", this._updateData);
629
+ this._map.off("resize", this._updateCompact);
630
+ this._map.off("drag", this._updateCompactMinimize);
631
+ }
632
+ if (this.printQuery && this.onMediaPrintChange) {
633
+ this.printQuery.removeEventListener("change", this.onMediaPrintChange);
634
+ }
635
+ this._map = void 0;
636
+ this._compact = void 0;
637
+ this._attribHTML = void 0;
638
+ }
639
+ _setElementTitle(element, title) {
640
+ if (!this._map) return;
641
+ const str = this._map._getUIString(`AttributionControl.${title}`);
642
+ element.title = str;
643
+ element.setAttribute("aria-label", str);
644
+ }
645
+ _toggleAttribution() {
646
+ if (!this._shadowContainer) return;
647
+ if (this._shadowContainer.classList.contains("maplibregl-compact")) {
648
+ if (this._shadowContainer.classList.contains("maplibregl-compact-show")) {
649
+ this._shadowContainer.setAttribute("open", "");
650
+ this._shadowContainer.classList.remove("maplibregl-compact-show");
651
+ } else {
652
+ this._shadowContainer.classList.add("maplibregl-compact-show");
653
+ this._shadowContainer.removeAttribute("open");
654
+ }
655
+ }
656
+ }
657
+ _updateData(e) {
658
+ if (e && (e.sourceDataType === "metadata" || e.sourceDataType === "visibility" || e.dataType === "style" || e.type === "terrain")) {
659
+ this._updateAttributions();
660
+ }
661
+ }
662
+ _updateAttributions() {
663
+ if (!this._map || !this._map.style) return;
664
+ let attributions = [];
665
+ if (this.options.customAttribution) {
666
+ if (Array.isArray(this.options.customAttribution)) {
667
+ attributions = attributions.concat(
668
+ this.options.customAttribution.filter(
669
+ (attr) => typeof attr === "string"
670
+ )
671
+ );
672
+ } else if (typeof this.options.customAttribution === "string") {
673
+ attributions.push(this.options.customAttribution);
674
+ }
675
+ }
676
+ if (this._map.style.stylesheet) {
677
+ const stylesheet = this._map.style.stylesheet;
678
+ this.styleOwner = stylesheet.owner;
679
+ this.styleId = stylesheet.id;
680
+ }
681
+ const sourceCaches = this._map.style.sourceCaches;
682
+ for (const id in sourceCaches) {
683
+ const sourceCache = sourceCaches[id];
684
+ if (sourceCache.used || sourceCache.usedForTerrain) {
685
+ const source = sourceCache.getSource();
686
+ if (source.attribution && attributions.indexOf(source.attribution) < 0) {
687
+ attributions.push(source.attribution);
688
+ }
689
+ }
690
+ }
691
+ attributions = attributions.filter((e) => String(e).trim());
692
+ attributions.sort((a, b) => a.length - b.length);
693
+ attributions = attributions.filter((attrib, i) => {
694
+ for (let j = i + 1; j < attributions.length; j++) {
695
+ if (attributions[j].indexOf(attrib) >= 0) {
696
+ return false;
697
+ }
698
+ }
699
+ return true;
700
+ });
701
+ const attribHTML = attributions.join(" | ");
702
+ if (attribHTML === this._attribHTML) return;
703
+ this._attribHTML = attribHTML;
704
+ if (attributions.length) {
705
+ this._innerContainer.innerHTML = attribHTML;
706
+ this._shadowContainer.classList.remove("maplibregl-attrib-empty");
707
+ } else {
708
+ this._shadowContainer.classList.add("maplibregl-attrib-empty");
709
+ }
710
+ this._updateCompact();
711
+ this._editLink = null;
712
+ }
713
+ _updateCompact() {
714
+ if (!this._map || !this._shadowContainer) return;
715
+ if (this._map.getCanvasContainer().offsetWidth <= 640 || this._compact) {
716
+ if (this._compact === false) {
717
+ this._shadowContainer.setAttribute("open", "");
718
+ } else if (!this._shadowContainer.classList.contains("maplibregl-compact") && !this._shadowContainer.classList.contains("maplibregl-attrib-empty")) {
719
+ this._shadowContainer.setAttribute("open", "");
720
+ this._shadowContainer.classList.add(
721
+ "maplibregl-compact",
722
+ "maplibregl-compact-show"
723
+ );
724
+ }
725
+ } else {
726
+ this._shadowContainer.setAttribute("open", "");
727
+ if (this._shadowContainer.classList.contains("maplibregl-compact")) {
728
+ this._shadowContainer.classList.remove(
729
+ "maplibregl-compact",
730
+ "maplibregl-compact-show"
731
+ );
732
+ }
733
+ }
734
+ }
735
+ _updateCompactMinimize() {
736
+ if (!this._shadowContainer) return;
737
+ if (this._shadowContainer.classList.contains("maplibregl-compact")) {
738
+ if (this._shadowContainer.classList.contains("maplibregl-compact-show")) {
739
+ this._shadowContainer.classList.remove("maplibregl-compact-show");
740
+ }
741
+ }
742
+ }
743
+ };
744
+ var attribution_default = CustomAttributionControl;
745
+
746
+ // src/lib/controls/geolonia-logo.ts
747
+ var GeoloniaControl = class {
748
+ onAdd() {
749
+ this.container = document.createElement("div");
750
+ this.container.className = "maplibregl-ctrl";
751
+ const img = document.createElement("img");
752
+ img.src = "https://cdn.geolonia.com/logo/geolonia-symbol_1.png";
753
+ img.style.width = "16px";
754
+ img.style.height = "16px";
755
+ img.style.display = "block";
756
+ img.style.cursor = "pointer";
757
+ img.style.padding = "0";
758
+ img.style.margin = "0";
759
+ img.style.border = "none";
760
+ img.alt = "Geolonia";
761
+ const link = document.createElement("a");
762
+ link.href = "https://geolonia.com/";
763
+ link.appendChild(img);
764
+ link.title = "Powered by Geolonia";
765
+ this.container.appendChild(link);
766
+ return this.container;
767
+ }
768
+ onRemove() {
769
+ this.container.parentNode?.removeChild(this.container);
770
+ }
771
+ getDefaultPosition() {
772
+ return "bottom-left";
773
+ }
774
+ };
775
+
776
+ // src/lib/geolonia-map.ts
777
+ var import_maplibre_gl4 = __toESM(require("maplibre-gl"), 1);
778
+ var import_pmtiles = require("pmtiles");
779
+
780
+ // src/lib/geolonia-marker.ts
781
+ var import_maplibre_gl = __toESM(require("maplibre-gl"), 1);
782
+ var import_tinycolor2 = __toESM(require("tinycolor2"), 1);
783
+ var MARKER_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 67">
784
+ <path class="left" d="M26 0C11.664 0 0 11.663 0 26c0 22.14 26 41 26 41V26h0C26 11.663 26 0 26 0z" fill="#E4402F"/>
785
+ <path class="right" d="M26 0c14.336 0 26 11.663 26 26 0 22.14-26 41-26 41V26h0C26 11.663 26 0 26 0z" fill="#C1272D"/>
786
+ <circle cx="26" cy="26" r="9" fill="#FFF"/>
787
+ </svg>`;
788
+ var DEFAULT_COLOR = "#E4402F";
789
+ var GeoloniaMarker = class extends import_maplibre_gl.default.Marker {
790
+ constructor(options = {}) {
791
+ if (!options.element) {
792
+ const markerElement = document.createElement("div");
793
+ markerElement.className = "geolonia-default-marker";
794
+ markerElement.innerHTML = MARKER_SVG;
795
+ markerElement.style.margin = "0";
796
+ markerElement.style.padding = "0";
797
+ markerElement.style.width = "26px";
798
+ markerElement.style.height = "34px";
799
+ const svg = markerElement.querySelector("svg");
800
+ if (svg) {
801
+ svg.style.width = "100%";
802
+ svg.style.height = "100%";
803
+ }
804
+ options.element = markerElement;
805
+ const color = options.color || DEFAULT_COLOR;
806
+ const left = markerElement.querySelector(".left");
807
+ const right = markerElement.querySelector(".right");
808
+ if (left) left.style.fill = color;
809
+ if (right) right.style.fill = (0, import_tinycolor2.default)(color).darken().toString();
810
+ options.offset = [0, -15];
811
+ }
812
+ super(options);
813
+ }
814
+ };
815
+
816
+ // src/lib/simplestyle.ts
817
+ var import_geojson_extent = __toESM(require("@mapbox/geojson-extent"), 1);
818
+ var import_center = __toESM(require("@turf/center"), 1);
819
+ var import_maplibre_gl2 = __toESM(require("maplibre-gl"), 1);
820
+
821
+ // src/lib/keyring.ts
822
+ var _apiKey, _stage, _isGeoloniaStyle;
823
+ var Keyring = class {
824
+ constructor() {
825
+ __privateAdd(this, _apiKey, "");
826
+ __privateAdd(this, _stage, "dev");
827
+ __privateAdd(this, _isGeoloniaStyle, true);
828
+ }
829
+ get apiKey() {
830
+ return __privateGet(this, _apiKey);
831
+ }
832
+ get stage() {
833
+ return __privateGet(this, _stage);
834
+ }
835
+ get isGeoloniaStyle() {
836
+ return __privateGet(this, _isGeoloniaStyle);
837
+ }
838
+ set isGeoloniaStyle(value) {
839
+ __privateSet(this, _isGeoloniaStyle, value);
840
+ }
841
+ setApiKey(key) {
842
+ __privateSet(this, _apiKey, key);
843
+ }
844
+ setStage(stage) {
845
+ __privateSet(this, _stage, stage);
846
+ }
847
+ reset() {
848
+ __privateSet(this, _apiKey, "");
849
+ __privateSet(this, _stage, "dev");
850
+ __privateSet(this, _isGeoloniaStyle, true);
851
+ }
852
+ /**
853
+ * Check if the given style is a Geolonia style (requires API key)
854
+ */
855
+ isGeoloniaStyleCheck(style) {
856
+ if (!style || style === "") {
857
+ return true;
858
+ }
859
+ if (style.startsWith("https://cdn.geolonia.com/style/") || style.startsWith("https://api.geolonia.com/")) {
860
+ return true;
861
+ }
862
+ if (style.match(/^https?:\/\//)) {
863
+ return false;
864
+ }
865
+ if (style.endsWith(".json")) {
866
+ return false;
867
+ }
868
+ return true;
869
+ }
870
+ };
871
+ _apiKey = new WeakMap();
872
+ _stage = new WeakMap();
873
+ _isGeoloniaStyle = new WeakMap();
874
+ var keyring = new Keyring();
875
+
876
+ // src/lib/util.ts
877
+ function isURL(str) {
878
+ if (str.match(/^https?:\/\//)) {
879
+ return str;
880
+ }
881
+ if (str.match(/^\//) || str.match(/^\.\.?/)) {
882
+ try {
883
+ return new URL(str, globalThis.location?.href).href;
884
+ } catch {
885
+ return false;
886
+ }
887
+ }
888
+ return false;
889
+ }
890
+ function isGeoloniaTilesHost(url) {
891
+ try {
892
+ const urlObj = typeof url === "string" ? new URL(url) : url;
893
+ return urlObj.hostname === "tileserver.geolonia.com" || urlObj.hostname.endsWith(".tiles.geolonia.com");
894
+ } catch {
895
+ return false;
896
+ }
897
+ }
898
+ function getStyle(style, options) {
899
+ const lang = options.lang || "en";
900
+ const apiKey = options.apiKey || keyring.apiKey;
901
+ if (keyring.isGeoloniaStyleCheck(style) && !apiKey) {
902
+ throw new Error("[Geolonia] API key is required to use Geolonia styles.");
903
+ }
904
+ if (!style || style === "") {
905
+ return `https://cdn.geolonia.com/style/geolonia/basic-v2/${lang === "ja" ? "ja" : "en"}.json`;
906
+ }
907
+ const styleUrl = isURL(style);
908
+ if (styleUrl) {
909
+ return styleUrl;
910
+ }
911
+ if (style.endsWith(".json")) {
912
+ try {
913
+ return new URL(style, globalThis.location?.href).href;
914
+ } catch {
915
+ return style;
916
+ }
917
+ }
918
+ return `https://cdn.geolonia.com/style/${style}/${lang === "ja" ? "ja" : "en"}.json`;
919
+ }
920
+ function getLang() {
921
+ if (typeof globalThis.navigator === "undefined") {
922
+ return "en";
923
+ }
924
+ const lang = globalThis.navigator.languages?.[0]?.toLowerCase() || globalThis.navigator.language?.toLowerCase();
925
+ return lang === "ja" || lang === "ja-jp" ? "ja" : "en";
926
+ }
927
+ var sessionId = "";
928
+ function getSessionId(digit) {
929
+ if (sessionId) {
930
+ return sessionId;
931
+ }
932
+ const array = new Uint8Array(digit / 2);
933
+ crypto.getRandomValues(array);
934
+ sessionId = Array.from(
935
+ array,
936
+ (dec) => dec.toString(16).padStart(2, "0")
937
+ ).join("");
938
+ return sessionId;
939
+ }
940
+ function parseControlOption(value) {
941
+ if (typeof value === "boolean") {
942
+ return { enabled: value, position: void 0 };
943
+ }
944
+ if (typeof value === "string") {
945
+ const positions = ["top-right", "bottom-right", "bottom-left", "top-left"];
946
+ if (positions.includes(value.toLowerCase())) {
947
+ return { enabled: true, position: value.toLowerCase() };
948
+ }
949
+ }
950
+ return { enabled: false, position: void 0 };
951
+ }
952
+ function parseSimpleVector(attributeValue) {
953
+ if (/^(https?|geolonia):\/\//.test(attributeValue)) {
954
+ return attributeValue;
955
+ }
956
+ return `geolonia://tiles/custom/${attributeValue}`;
957
+ }
958
+ function handleRestrictedMode(map) {
959
+ if (!map._geolonia_restricted_mode_handled) {
960
+ map._geolonia_restricted_mode_handled = true;
961
+ const container = map.getContainer();
962
+ map.remove();
963
+ container.innerHTML = "";
964
+ container.classList.add("geolonia__restricted-mode-image-container");
965
+ }
966
+ }
967
+ function handleErrorMode(container) {
968
+ const errorContainer = document.createElement("div");
969
+ errorContainer.classList.add("geolonia__error-container");
970
+ const div = document.createElement("div");
971
+ const h2 = document.createElement("h2");
972
+ h2.textContent = "Geolonia Maps";
973
+ div.appendChild(h2);
974
+ div.classList.add("geolonia__error-message");
975
+ div.innerHTML += '<div class="geolonia__error-message-description">\u5730\u56F3\u306E\u521D\u671F\u5316\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3002\u7BA1\u7406\u8005\u306B\u304A\u554F\u3044\u5408\u308F\u305B\u4E0B\u3055\u3044\u3002</div>';
976
+ errorContainer.appendChild(div);
977
+ container.appendChild(errorContainer);
978
+ }
979
+ async function sanitizeDescription(description) {
980
+ const { default: sanitizeHtml } = await import("sanitize-html");
981
+ return sanitizeHtml(description, {
982
+ allowedTags: sanitizeHtml.defaults.allowedTags.concat(["img"]),
983
+ allowedAttributes: {
984
+ ...sanitizeHtml.defaults.allowedAttributes,
985
+ "*": ["class"]
986
+ }
987
+ });
988
+ }
989
+ function loadImageCompatibility(promise, callback) {
990
+ promise.then((response) => {
991
+ callback(null, response.data, {
992
+ cacheControl: response.cacheControl,
993
+ expires: response.expires
994
+ });
995
+ }).catch((error) => {
996
+ callback(error);
997
+ });
998
+ }
999
+
1000
+ // src/lib/simplestyle.ts
1001
+ var textColor = "#000000";
1002
+ var textHaloColor = "#FFFFFF";
1003
+ var backgroundColor = "rgba(255, 0, 0, 0.4)";
1004
+ var strokeColor = "#FFFFFF";
1005
+ var template = {
1006
+ type: "FeatureCollection",
1007
+ features: []
1008
+ };
1009
+ var SimpleStyle = class {
1010
+ constructor(geojson, options) {
1011
+ this.callFitBounds = false;
1012
+ this._eventHandlers = [];
1013
+ this.setGeoJSON(geojson);
1014
+ this.options = {
1015
+ id: "geolonia-simple-style",
1016
+ cluster: true,
1017
+ heatmap: false,
1018
+ // TODO: It should support heatmap.
1019
+ clusterColor: "#ff0000",
1020
+ ...options
1021
+ };
1022
+ }
1023
+ updateData(geojson) {
1024
+ this.setGeoJSON(geojson);
1025
+ const features = this.geojson.features;
1026
+ const polygonAndLines = features.filter(
1027
+ (feature) => feature.geometry.type.toLowerCase() !== "point"
1028
+ );
1029
+ const points = features.filter(
1030
+ (feature) => feature.geometry.type.toLowerCase() === "point"
1031
+ );
1032
+ this.map.getSource(this.options.id).setData({
1033
+ type: "FeatureCollection",
1034
+ features: polygonAndLines
1035
+ });
1036
+ this.map.getSource(`${this.options.id}-points`).setData({
1037
+ type: "FeatureCollection",
1038
+ features: points
1039
+ });
1040
+ return this;
1041
+ }
1042
+ addTo(map) {
1043
+ this.map = map;
1044
+ const features = this.geojson.features;
1045
+ const polygonAndLines = features.filter(
1046
+ (feature) => feature.geometry.type.toLowerCase() !== "point"
1047
+ );
1048
+ const points = features.filter(
1049
+ (feature) => feature.geometry.type.toLowerCase() === "point"
1050
+ );
1051
+ this.map.addSource(this.options.id, {
1052
+ type: "geojson",
1053
+ data: {
1054
+ type: "FeatureCollection",
1055
+ features: polygonAndLines
1056
+ }
1057
+ });
1058
+ this.setPolygonGeometries();
1059
+ this.setLineGeometries();
1060
+ this.map.addSource(`${this.options.id}-points`, {
1061
+ type: "geojson",
1062
+ data: {
1063
+ type: "FeatureCollection",
1064
+ features: points
1065
+ },
1066
+ cluster: this.options.cluster,
1067
+ clusterMaxZoom: 14,
1068
+ clusterRadius: 50
1069
+ });
1070
+ this.map.addLayer({
1071
+ id: `${this.options.id}-polygon-symbol`,
1072
+ type: "symbol",
1073
+ source: this.options.id,
1074
+ filter: ["==", "$type", "Polygon"],
1075
+ paint: {
1076
+ "text-color": ["string", ["get", "text-color"], textColor],
1077
+ "text-halo-color": [
1078
+ "string",
1079
+ ["get", "text-halo-color"],
1080
+ textHaloColor
1081
+ ],
1082
+ "text-halo-width": 1
1083
+ },
1084
+ layout: {
1085
+ "text-field": ["get", "title"],
1086
+ "text-font": ["Noto Sans Regular"],
1087
+ "text-size": 12,
1088
+ "text-max-width": 12,
1089
+ "text-allow-overlap": false
1090
+ }
1091
+ });
1092
+ this.map.addLayer({
1093
+ id: `${this.options.id}-linestring-symbol`,
1094
+ type: "symbol",
1095
+ source: this.options.id,
1096
+ filter: ["==", "$type", "LineString"],
1097
+ paint: {
1098
+ "text-color": ["string", ["get", "text-color"], textColor],
1099
+ "text-halo-color": [
1100
+ "string",
1101
+ ["get", "text-halo-color"],
1102
+ textHaloColor
1103
+ ],
1104
+ "text-halo-width": 1
1105
+ },
1106
+ layout: {
1107
+ "symbol-placement": "line",
1108
+ "text-field": ["get", "title"],
1109
+ "text-font": ["Noto Sans Regular"],
1110
+ "text-size": 12,
1111
+ "text-max-width": 12,
1112
+ "text-allow-overlap": false
1113
+ }
1114
+ });
1115
+ this.setPointGeometries();
1116
+ this.setCluster();
1117
+ return this;
1118
+ }
1119
+ fitBounds(options = {}) {
1120
+ this.callFitBounds = true;
1121
+ const _options = {
1122
+ duration: 3e3,
1123
+ padding: 30,
1124
+ ...options
1125
+ };
1126
+ const bounds = (0, import_geojson_extent.default)(this.geojson);
1127
+ if (bounds) {
1128
+ window.requestAnimationFrame(() => {
1129
+ this.map.fitBounds(bounds, _options);
1130
+ });
1131
+ }
1132
+ return this;
1133
+ }
1134
+ /**
1135
+ * Set polygon geometries.
1136
+ */
1137
+ setPolygonGeometries() {
1138
+ this.map.addLayer({
1139
+ id: `${this.options.id}-polygon`,
1140
+ type: "fill",
1141
+ source: this.options.id,
1142
+ filter: ["==", "$type", "Polygon"],
1143
+ paint: {
1144
+ "fill-color": ["string", ["get", "fill"], backgroundColor],
1145
+ "fill-opacity": ["number", ["get", "fill-opacity"], 1],
1146
+ "fill-outline-color": ["string", ["get", "stroke"], strokeColor]
1147
+ }
1148
+ });
1149
+ this.setPopup(this.map, `${this.options.id}-polygon`);
1150
+ }
1151
+ /**
1152
+ * Set line geometries.
1153
+ */
1154
+ setLineGeometries() {
1155
+ this.map.addLayer({
1156
+ id: `${this.options.id}-linestring`,
1157
+ type: "line",
1158
+ source: this.options.id,
1159
+ filter: ["==", "$type", "LineString"],
1160
+ paint: {
1161
+ "line-width": ["number", ["get", "stroke-width"], 2],
1162
+ "line-color": ["string", ["get", "stroke"], backgroundColor],
1163
+ "line-opacity": ["number", ["get", "stroke-opacity"], 1]
1164
+ },
1165
+ layout: {
1166
+ "line-cap": "round",
1167
+ "line-join": "round"
1168
+ }
1169
+ });
1170
+ this.setPopup(this.map, `${this.options.id}-linestring`);
1171
+ }
1172
+ /**
1173
+ * Setup point geometries.
1174
+ */
1175
+ setPointGeometries() {
1176
+ this.map.addLayer({
1177
+ id: `${this.options.id}-circle-points`,
1178
+ type: "circle",
1179
+ source: `${this.options.id}-points`,
1180
+ filter: ["all", ["!has", "point_count"], ["!has", "marker-symbol"]],
1181
+ paint: {
1182
+ "circle-radius": [
1183
+ "case",
1184
+ ["==", "small", ["get", "marker-size"]],
1185
+ 7,
1186
+ ["==", "large", ["get", "marker-size"]],
1187
+ 13,
1188
+ 9
1189
+ ],
1190
+ "circle-color": ["string", ["get", "marker-color"], backgroundColor],
1191
+ "circle-opacity": ["number", ["get", "fill-opacity"], 1],
1192
+ "circle-stroke-width": ["number", ["get", "stroke-width"], 1],
1193
+ "circle-stroke-color": ["string", ["get", "stroke"], strokeColor],
1194
+ "circle-stroke-opacity": ["number", ["get", "stroke-opacity"], 1]
1195
+ }
1196
+ });
1197
+ this.map.addLayer({
1198
+ id: `${this.options.id}-symbol-points`,
1199
+ type: "symbol",
1200
+ source: `${this.options.id}-points`,
1201
+ filter: ["!", ["has", "point_count"]],
1202
+ paint: {
1203
+ "text-color": ["string", ["get", "text-color"], textColor],
1204
+ "text-halo-color": [
1205
+ "string",
1206
+ ["get", "text-halo-color"],
1207
+ textHaloColor
1208
+ ],
1209
+ "text-halo-width": 1
1210
+ },
1211
+ layout: {
1212
+ "icon-image": ["get", "marker-symbol"],
1213
+ "text-field": ["get", "title"],
1214
+ "text-font": ["Noto Sans Regular"],
1215
+ "text-size": 12,
1216
+ "text-max-width": 12,
1217
+ "text-allow-overlap": true,
1218
+ "icon-allow-overlap": true,
1219
+ "text-variable-anchor": ["top", "bottom", "left", "right"],
1220
+ "text-radial-offset": [
1221
+ "case",
1222
+ ["==", "small", ["get", "marker-size"]],
1223
+ 1,
1224
+ ["==", "large", ["get", "marker-size"]],
1225
+ 1.6,
1226
+ 1.2
1227
+ ]
1228
+ }
1229
+ });
1230
+ this.setPopup(this.map, `${this.options.id}-circle-points`);
1231
+ this.setPopup(this.map, `${this.options.id}-symbol-points`);
1232
+ }
1233
+ async setPopup(map, source) {
1234
+ const clickHandler = async (e) => {
1235
+ const center = (0, import_center.default)(e.features[0]).geometry.coordinates;
1236
+ const description = e.features[0].properties.description;
1237
+ if (description) {
1238
+ const sanitizedDescription = await sanitizeDescription(description);
1239
+ new import_maplibre_gl2.default.Popup().setLngLat(center).setHTML(sanitizedDescription).addTo(map);
1240
+ }
1241
+ };
1242
+ const mouseEnterHandler = (e) => {
1243
+ if (e.features[0].properties.description) {
1244
+ map.getCanvas().style.cursor = "pointer";
1245
+ }
1246
+ };
1247
+ const mouseLeaveHandler = () => {
1248
+ map.getCanvas().style.cursor = "";
1249
+ };
1250
+ map.on("click", source, clickHandler);
1251
+ map.on("mouseenter", source, mouseEnterHandler);
1252
+ map.on("mouseleave", source, mouseLeaveHandler);
1253
+ this._eventHandlers.push(
1254
+ { event: "click", layer: source, handler: clickHandler },
1255
+ { event: "mouseenter", layer: source, handler: mouseEnterHandler },
1256
+ { event: "mouseleave", layer: source, handler: mouseLeaveHandler }
1257
+ );
1258
+ }
1259
+ /**
1260
+ * Setup cluster markers
1261
+ */
1262
+ setCluster() {
1263
+ this.map.addLayer({
1264
+ id: `${this.options.id}-clusters`,
1265
+ type: "circle",
1266
+ source: `${this.options.id}-points`,
1267
+ filter: ["has", "point_count"],
1268
+ paint: {
1269
+ "circle-radius": 20,
1270
+ "circle-color": this.options.clusterColor,
1271
+ "circle-opacity": 1
1272
+ }
1273
+ });
1274
+ this.map.addLayer({
1275
+ id: `${this.options.id}-cluster-count`,
1276
+ type: "symbol",
1277
+ source: `${this.options.id}-points`,
1278
+ filter: ["has", "point_count"],
1279
+ layout: {
1280
+ "text-field": "{point_count_abbreviated}",
1281
+ "text-size": 14,
1282
+ "text-font": ["Noto Sans Regular"]
1283
+ }
1284
+ });
1285
+ const clusterLayer = `${this.options.id}-clusters`;
1286
+ const clusterClickHandler = async (e) => {
1287
+ const features = this.map.queryRenderedFeatures(e.point, {
1288
+ layers: [clusterLayer]
1289
+ });
1290
+ const clusterId = features[0].properties.cluster_id;
1291
+ const zoom = await this.map.getSource(`${this.options.id}-points`).getClusterExpansionZoom(clusterId);
1292
+ this.map.easeTo({
1293
+ center: features[0].geometry.coordinates,
1294
+ zoom
1295
+ });
1296
+ };
1297
+ const clusterEnterHandler = () => {
1298
+ this.map.getCanvas().style.cursor = "pointer";
1299
+ };
1300
+ const clusterLeaveHandler = () => {
1301
+ this.map.getCanvas().style.cursor = "";
1302
+ };
1303
+ this.map.on("click", clusterLayer, clusterClickHandler);
1304
+ this.map.on("mouseenter", clusterLayer, clusterEnterHandler);
1305
+ this.map.on("mouseleave", clusterLayer, clusterLeaveHandler);
1306
+ this._eventHandlers.push(
1307
+ { event: "click", layer: clusterLayer, handler: clusterClickHandler },
1308
+ {
1309
+ event: "mouseenter",
1310
+ layer: clusterLayer,
1311
+ handler: clusterEnterHandler
1312
+ },
1313
+ {
1314
+ event: "mouseleave",
1315
+ layer: clusterLayer,
1316
+ handler: clusterLeaveHandler
1317
+ }
1318
+ );
1319
+ }
1320
+ remove() {
1321
+ if (!this.map) return this;
1322
+ const id = this.options.id;
1323
+ for (const { event, layer, handler } of this._eventHandlers) {
1324
+ this.map.off(event, layer, handler);
1325
+ }
1326
+ this._eventHandlers = [];
1327
+ const layerIds = [
1328
+ `${id}-polygon-symbol`,
1329
+ `${id}-linestring-symbol`,
1330
+ `${id}-circle-points`,
1331
+ `${id}-symbol-points`,
1332
+ `${id}-polygon`,
1333
+ `${id}-linestring`,
1334
+ `${id}-clusters`,
1335
+ `${id}-cluster-count`
1336
+ ];
1337
+ for (const layerId of layerIds) {
1338
+ if (this.map.getLayer(layerId)) {
1339
+ this.map.removeLayer(layerId);
1340
+ }
1341
+ }
1342
+ for (const sourceId of [id, `${id}-points`]) {
1343
+ if (this.map.getSource(sourceId)) {
1344
+ this.map.removeSource(sourceId);
1345
+ }
1346
+ }
1347
+ this.map.getCanvas().style.cursor = "";
1348
+ return this;
1349
+ }
1350
+ setGeoJSON(geojson) {
1351
+ if (typeof geojson === "string" && isURL(geojson)) {
1352
+ this.geojson = template;
1353
+ const fetchGeoJSON = async () => {
1354
+ try {
1355
+ const response = await window.fetch(geojson);
1356
+ const data = response.ok ? await response.json() : {};
1357
+ this.geojson = data;
1358
+ this.updateData(data);
1359
+ if (this.callFitBounds) {
1360
+ this.fitBounds();
1361
+ this.callFitBounds = false;
1362
+ }
1363
+ } catch (error) {
1364
+ console.error("[Geolonia] Failed to load GeoJSON:", error);
1365
+ }
1366
+ };
1367
+ this._loadingPromise = fetchGeoJSON();
1368
+ } else {
1369
+ this.geojson = geojson;
1370
+ }
1371
+ }
1372
+ };
1373
+
1374
+ // src/lib/simplestyle-vector.ts
1375
+ var import_center2 = __toESM(require("@turf/center"), 1);
1376
+ var import_maplibre_gl3 = __toESM(require("maplibre-gl"), 1);
1377
+ var textColor2 = "#000000";
1378
+ var textHaloColor2 = "#FFFFFF";
1379
+ var backgroundColor2 = "rgba(255, 0, 0, 0.4)";
1380
+ var strokeColor2 = "#FFFFFF";
1381
+ var SimpleStyleVector = class {
1382
+ constructor(url) {
1383
+ this.url = url;
1384
+ this.sourceName = "vt-geolonia-simple-style";
1385
+ }
1386
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1387
+ addTo(map) {
1388
+ const container = map.getContainer();
1389
+ if (!container.dataset || !container.dataset.lng && !container.dataset.lat) {
1390
+ let initialZoomDone = false;
1391
+ map.on("sourcedata", (event) => {
1392
+ if (event.sourceId !== this.sourceName) {
1393
+ return;
1394
+ }
1395
+ const source = map.getSource(event.sourceId);
1396
+ const isLoaded = source && source.loaded();
1397
+ if (isLoaded !== true) {
1398
+ return;
1399
+ }
1400
+ if (initialZoomDone) {
1401
+ return;
1402
+ }
1403
+ initialZoomDone = true;
1404
+ map.fitBounds(source.bounds, {
1405
+ duration: 0,
1406
+ padding: 30
1407
+ });
1408
+ });
1409
+ }
1410
+ map.addSource(this.sourceName, {
1411
+ type: "vector",
1412
+ url: this.url
1413
+ });
1414
+ this.setPolygonGeometries(map);
1415
+ this.setLineGeometries(map);
1416
+ map.addLayer({
1417
+ id: "vt-geolonia-simple-style-polygon-symbol",
1418
+ type: "symbol",
1419
+ source: this.sourceName,
1420
+ "source-layer": "g-simplestyle-v1",
1421
+ filter: ["==", "$type", "Polygon"],
1422
+ paint: {
1423
+ "text-color": ["string", ["get", "text-color"], textColor2],
1424
+ "text-halo-color": [
1425
+ "string",
1426
+ ["get", "text-halo-color"],
1427
+ textHaloColor2
1428
+ ],
1429
+ "text-halo-width": 1
1430
+ },
1431
+ layout: {
1432
+ "text-field": ["get", "title"],
1433
+ "text-font": ["Noto Sans Regular"],
1434
+ "text-size": 12,
1435
+ "text-max-width": 12,
1436
+ "text-allow-overlap": false
1437
+ }
1438
+ });
1439
+ map.addLayer({
1440
+ id: "vt-geolonia-simple-style-linestring-symbol",
1441
+ type: "symbol",
1442
+ source: this.sourceName,
1443
+ "source-layer": "g-simplestyle-v1",
1444
+ filter: ["==", "$type", "LineString"],
1445
+ paint: {
1446
+ "text-color": ["string", ["get", "text-color"], textColor2],
1447
+ "text-halo-color": [
1448
+ "string",
1449
+ ["get", "text-halo-color"],
1450
+ textHaloColor2
1451
+ ],
1452
+ "text-halo-width": 1
1453
+ },
1454
+ layout: {
1455
+ "symbol-placement": "line",
1456
+ "text-field": ["get", "title"],
1457
+ "text-font": ["Noto Sans Regular"],
1458
+ "text-size": 12,
1459
+ "text-max-width": 12,
1460
+ "text-allow-overlap": false
1461
+ }
1462
+ });
1463
+ this.setPointGeometries(map);
1464
+ }
1465
+ /**
1466
+ * Set polygon geometries.
1467
+ *
1468
+ * @param map
1469
+ */
1470
+ setPolygonGeometries(map) {
1471
+ map.addLayer({
1472
+ id: "vt-geolonia-simple-style-polygon",
1473
+ type: "fill",
1474
+ source: this.sourceName,
1475
+ "source-layer": "g-simplestyle-v1",
1476
+ filter: ["==", "$type", "Polygon"],
1477
+ paint: {
1478
+ "fill-color": ["string", ["get", "fill"], backgroundColor2],
1479
+ "fill-opacity": ["number", ["get", "fill-opacity"], 1],
1480
+ "fill-outline-color": ["string", ["get", "stroke"], strokeColor2]
1481
+ }
1482
+ });
1483
+ this.setPopup(map, "vt-geolonia-simple-style-polygon");
1484
+ }
1485
+ /**
1486
+ * Set line geometries.
1487
+ *
1488
+ * @param map
1489
+ */
1490
+ setLineGeometries(map) {
1491
+ map.addLayer({
1492
+ id: "vt-geolonia-simple-style-linestring",
1493
+ type: "line",
1494
+ source: this.sourceName,
1495
+ "source-layer": "g-simplestyle-v1",
1496
+ filter: ["==", "$type", "LineString"],
1497
+ paint: {
1498
+ "line-width": ["number", ["get", "stroke-width"], 2],
1499
+ "line-color": ["string", ["get", "stroke"], backgroundColor2],
1500
+ "line-opacity": ["number", ["get", "stroke-opacity"], 1]
1501
+ },
1502
+ layout: {
1503
+ "line-cap": "round",
1504
+ "line-join": "round"
1505
+ }
1506
+ });
1507
+ this.setPopup(map, "vt-geolonia-simple-style-linestring");
1508
+ }
1509
+ /**
1510
+ * Setup point geometries.
1511
+ *
1512
+ * @param map
1513
+ */
1514
+ setPointGeometries(map) {
1515
+ map.addLayer({
1516
+ id: "vt-circle-simple-style-points",
1517
+ type: "circle",
1518
+ source: this.sourceName,
1519
+ "source-layer": "g-simplestyle-v1",
1520
+ filter: ["all", ["==", "$type", "Point"], ["!has", "marker-symbol"]],
1521
+ paint: {
1522
+ "circle-radius": [
1523
+ "case",
1524
+ ["==", "small", ["get", "marker-size"]],
1525
+ 7,
1526
+ ["==", "large", ["get", "marker-size"]],
1527
+ 13,
1528
+ 9
1529
+ ],
1530
+ "circle-color": ["string", ["get", "marker-color"], backgroundColor2],
1531
+ "circle-opacity": ["number", ["get", "fill-opacity"], 1],
1532
+ "circle-stroke-width": ["number", ["get", "stroke-width"], 1],
1533
+ "circle-stroke-color": ["string", ["get", "stroke"], strokeColor2],
1534
+ "circle-stroke-opacity": ["number", ["get", "stroke-opacity"], 1]
1535
+ }
1536
+ });
1537
+ map.addLayer({
1538
+ id: "vt-geolonia-simple-style-points",
1539
+ type: "symbol",
1540
+ source: this.sourceName,
1541
+ "source-layer": "g-simplestyle-v1",
1542
+ filter: ["==", "$type", "Point"],
1543
+ paint: {
1544
+ "text-color": ["string", ["get", "text-color"], textColor2],
1545
+ "text-halo-color": [
1546
+ "string",
1547
+ ["get", "text-halo-color"],
1548
+ textHaloColor2
1549
+ ],
1550
+ "text-halo-width": 1
1551
+ },
1552
+ layout: {
1553
+ "icon-image": ["get", "marker-symbol"],
1554
+ "text-field": ["get", "title"],
1555
+ "text-font": ["Noto Sans Regular"],
1556
+ "text-size": 12,
1557
+ "text-anchor": "top",
1558
+ "text-max-width": 12,
1559
+ "text-offset": [
1560
+ "case",
1561
+ ["==", "small", ["get", "marker-size"]],
1562
+ ["literal", [0, 1]],
1563
+ ["==", "large", ["get", "marker-size"]],
1564
+ ["literal", [0, 1.6]],
1565
+ ["literal", [0, 1.2]]
1566
+ ],
1567
+ "text-allow-overlap": false
1568
+ }
1569
+ });
1570
+ this.setPopup(map, "vt-circle-simple-style-points");
1571
+ this.setPopup(map, "vt-geolonia-simple-style-points");
1572
+ }
1573
+ async setPopup(map, source) {
1574
+ map.on("click", source, async (e) => {
1575
+ const center = (0, import_center2.default)(e.features[0]).geometry.coordinates;
1576
+ const description = e.features[0].properties.description;
1577
+ if (description) {
1578
+ const sanitizedDescription = await sanitizeDescription(description);
1579
+ new import_maplibre_gl3.default.Popup().setLngLat(center).setHTML(sanitizedDescription).addTo(map);
1580
+ }
1581
+ });
1582
+ map.on("mouseenter", source, (e) => {
1583
+ if (e.features[0].properties.description) {
1584
+ map.getCanvas().style.cursor = "pointer";
1585
+ }
1586
+ });
1587
+ map.on("mouseleave", source, () => {
1588
+ map.getCanvas().style.cursor = "";
1589
+ });
1590
+ }
1591
+ };
1592
+ var simplestyle_vector_default = SimpleStyleVector;
1593
+
1594
+ // src/lib/geolonia-map.ts
1595
+ var pmtilesRegistered = false;
1596
+ function ensurePMTiles() {
1597
+ if (pmtilesRegistered) return;
1598
+ pmtilesRegistered = true;
1599
+ const protocol = new import_pmtiles.Protocol();
1600
+ import_maplibre_gl4.default.addProtocol("pmtiles", protocol.tile);
1601
+ }
1602
+ var GeoloniaMap = class extends import_maplibre_gl4.default.Map {
1603
+ constructor(options) {
1604
+ ensurePMTiles();
1605
+ if (options.apiKey) {
1606
+ keyring.setApiKey(options.apiKey);
1607
+ }
1608
+ if (options.stage) {
1609
+ keyring.setStage(options.stage);
1610
+ }
1611
+ const lang = options.lang === "auto" || !options.lang ? getLang() : options.lang;
1612
+ const styleName = options.style || "geolonia/basic-v2";
1613
+ keyring.isGeoloniaStyle = keyring.isGeoloniaStyleCheck(styleName);
1614
+ const resolvedStyle = getStyle(styleName, {
1615
+ lang,
1616
+ apiKey: options.apiKey || keyring.apiKey
1617
+ });
1618
+ const container = typeof options.container === "string" ? document.querySelector(options.container) || document.getElementById(options.container) : options.container;
1619
+ if (!container) {
1620
+ throw new Error(
1621
+ `[Geolonia] No HTML elements found. Please ensure the map container element exists.`
1622
+ );
1623
+ }
1624
+ if (container.geoloniaMap) {
1625
+ return container.geoloniaMap;
1626
+ }
1627
+ const apiKey = options.apiKey || keyring.apiKey;
1628
+ const stage = options.stage || keyring.stage;
1629
+ const apiUrl = `https://api.geolonia.com/${stage}`;
1630
+ const sessionId2 = getSessionId(40);
1631
+ const sourcesUrl = new URL(`${apiUrl}/sources`);
1632
+ sourcesUrl.searchParams.set("key", apiKey);
1633
+ sourcesUrl.searchParams.set("sessionId", sessionId2);
1634
+ const userTransformRequest = options.transformRequest;
1635
+ const transformRequest = (url, resourceType) => {
1636
+ if (resourceType === "Source" && url.startsWith("https://api.geolonia.com")) {
1637
+ return { url: sourcesUrl.toString() };
1638
+ }
1639
+ let transformedUrl = url;
1640
+ if (url.startsWith("geolonia://")) {
1641
+ const tilesMatch = url.match(
1642
+ /^geolonia:\/\/tiles\/(?<username>.+)\/(?<customtileId>.+)/
1643
+ );
1644
+ if (tilesMatch?.groups) {
1645
+ transformedUrl = `https://tileserver.geolonia.com/customtiles/${tilesMatch.groups.customtileId}/tiles.json`;
1646
+ }
1647
+ }
1648
+ const transformedUrlObj = new URL(transformedUrl);
1649
+ const geoloniaTilesHost = isGeoloniaTilesHost(transformedUrlObj);
1650
+ if (resourceType === "Source" && geoloniaTilesHost) {
1651
+ if (stage === "dev" && transformedUrlObj.hostname === "tileserver.geolonia.com") {
1652
+ transformedUrlObj.hostname = "tileserver-dev.geolonia.com";
1653
+ }
1654
+ transformedUrlObj.searchParams.set("sessionId", sessionId2);
1655
+ transformedUrlObj.searchParams.set("key", apiKey);
1656
+ return { url: transformedUrlObj.toString() };
1657
+ }
1658
+ if ((resourceType === "SpriteJSON" || resourceType === "SpriteImage") && transformedUrl.match(
1659
+ /^https:\/\/api\.geolonia\.com\/(dev|v1)\/sprites\//
1660
+ )) {
1661
+ const pathParts = transformedUrlObj.pathname.split("/");
1662
+ pathParts[1] = stage;
1663
+ transformedUrlObj.pathname = pathParts.join("/");
1664
+ transformedUrlObj.searchParams.set("key", apiKey);
1665
+ return { url: transformedUrlObj.toString() };
1666
+ }
1667
+ if (typeof userTransformRequest === "function") {
1668
+ return userTransformRequest(transformedUrl, resourceType);
1669
+ }
1670
+ return void 0;
1671
+ };
1672
+ let loading;
1673
+ const showLoader = options.loader !== false;
1674
+ if (showLoader) {
1675
+ loading = document.createElement("div");
1676
+ loading.className = "loading-geolonia-map";
1677
+ loading.innerHTML = `<div class="lds-grid"><div></div><div></div><div></div>
1678
+ <div></div><div></div><div></div><div></div><div></div><div></div></div>`;
1679
+ container.appendChild(loading);
1680
+ }
1681
+ const mapOptions = {
1682
+ ...options,
1683
+ container,
1684
+ style: resolvedStyle,
1685
+ hash: options.hash ?? false,
1686
+ localIdeographFontFamily: options.localIdeographFontFamily ?? "sans-serif",
1687
+ attributionControl: false,
1688
+ transformRequest
1689
+ };
1690
+ for (const key of [
1691
+ "apiKey",
1692
+ "stage",
1693
+ "lang",
1694
+ "marker",
1695
+ "markerColor",
1696
+ "openPopup",
1697
+ "customMarker",
1698
+ "customMarkerOffset",
1699
+ "loader",
1700
+ "gestureHandling",
1701
+ "navigationControl",
1702
+ "geolocateControl",
1703
+ "fullscreenControl",
1704
+ "scaleControl",
1705
+ "geoloniaControl",
1706
+ "geojson",
1707
+ "cluster",
1708
+ "clusterColor",
1709
+ "simpleVector",
1710
+ "3d"
1711
+ ]) {
1712
+ delete mapOptions[key];
1713
+ }
1714
+ try {
1715
+ super(mapOptions);
1716
+ } catch (error) {
1717
+ handleErrorMode(container);
1718
+ throw error;
1719
+ }
1720
+ this.geoloniaSourcesUrl = sourcesUrl;
1721
+ this.__styleExtensionLoadRequired = true;
1722
+ const geoloniaCtrl = parseControlOption(options.geoloniaControl ?? true);
1723
+ this.addControl(
1724
+ new GeoloniaControl(),
1725
+ geoloniaCtrl.position
1726
+ );
1727
+ this.addControl(new attribution_default(), "bottom-right");
1728
+ const fullscreen = parseControlOption(options.fullscreenControl ?? false);
1729
+ if (fullscreen.enabled) {
1730
+ this.addControl(
1731
+ new import_maplibre_gl4.FullscreenControl(),
1732
+ fullscreen.position
1733
+ );
1734
+ }
1735
+ const nav = parseControlOption(options.navigationControl ?? true);
1736
+ if (nav.enabled) {
1737
+ this.addControl(new import_maplibre_gl4.NavigationControl(), nav.position);
1738
+ }
1739
+ const geolocate = parseControlOption(options.geolocateControl ?? false);
1740
+ if (geolocate.enabled) {
1741
+ this.addControl(
1742
+ new import_maplibre_gl4.GeolocateControl({}),
1743
+ geolocate.position
1744
+ );
1745
+ }
1746
+ const scale = parseControlOption(options.scaleControl ?? false);
1747
+ if (scale.enabled) {
1748
+ this.addControl(new import_maplibre_gl4.ScaleControl({}), scale.position);
1749
+ }
1750
+ this.on("load", (event) => {
1751
+ const map = event.target;
1752
+ if (loading) {
1753
+ try {
1754
+ container.removeChild(loading);
1755
+ } catch {
1756
+ }
1757
+ }
1758
+ if (options.gestureHandling !== false) {
1759
+ import("@geolonia/mbgl-gesture-handling").then(({ default: GestureHandling }) => {
1760
+ const body = document.body;
1761
+ const html = document.documentElement;
1762
+ const isScrollable = body.scrollHeight > body.clientHeight || html.scrollHeight > html.clientHeight;
1763
+ if (isScrollable) {
1764
+ new GestureHandling({ lang }).addTo(map);
1765
+ }
1766
+ }).catch(() => {
1767
+ });
1768
+ }
1769
+ if (options.marker && options.center) {
1770
+ const c = options.center;
1771
+ const center = Array.isArray(c) ? [c[0], c[1]] : "lng" in c ? [c.lng, c.lat] : [c.lon, c.lat];
1772
+ let marker;
1773
+ if (options.customMarker) {
1774
+ const customEl = document.querySelector(
1775
+ options.customMarker
1776
+ );
1777
+ if (customEl) {
1778
+ customEl.style.display = "block";
1779
+ marker = new GeoloniaMarker({
1780
+ element: customEl,
1781
+ offset: options.customMarkerOffset || [0, 0]
1782
+ }).setLngLat(center).addTo(map);
1783
+ } else {
1784
+ marker = new GeoloniaMarker({ color: options.markerColor }).setLngLat(center).addTo(map);
1785
+ }
1786
+ } else {
1787
+ marker = new GeoloniaMarker({ color: options.markerColor }).setLngLat(center).addTo(map);
1788
+ }
1789
+ const content = container.dataset?.popupContent;
1790
+ if (content) {
1791
+ const popup = new import_maplibre_gl4.Popup({ offset: [0, -25] }).setHTML(content);
1792
+ marker.setPopup(popup);
1793
+ if (options.openPopup) {
1794
+ marker.togglePopup();
1795
+ }
1796
+ } else if (options.openPopup) {
1797
+ }
1798
+ marker.getElement().classList.add("geolonia-clickable-marker");
1799
+ }
1800
+ });
1801
+ this.on("styledata", async () => {
1802
+ if (!this.__styleExtensionLoadRequired) {
1803
+ return;
1804
+ }
1805
+ this.__styleExtensionLoadRequired = false;
1806
+ if (options.simpleVector) {
1807
+ const url = parseSimpleVector(options.simpleVector);
1808
+ new simplestyle_vector_default(url).addTo(this);
1809
+ }
1810
+ if (options.geojson) {
1811
+ const ss = new SimpleStyle(options.geojson, {
1812
+ cluster: options.cluster !== false,
1813
+ clusterColor: options.clusterColor || "#ff0000"
1814
+ });
1815
+ ss.addTo(this);
1816
+ if (!options.center) {
1817
+ ss.fitBounds();
1818
+ }
1819
+ }
1820
+ if (options["3d"] === true) {
1821
+ const style = this.getStyle();
1822
+ if (style?.layers) {
1823
+ for (const layer of style.layers) {
1824
+ const metadata = layer.metadata;
1825
+ if (metadata?.["visible-on-3d"]) {
1826
+ this.setLayoutProperty(layer.id, "visibility", "visible");
1827
+ }
1828
+ if (metadata?.["hide-on-3d"]) {
1829
+ this.setLayoutProperty(layer.id, "visibility", "none");
1830
+ }
1831
+ }
1832
+ }
1833
+ }
1834
+ });
1835
+ this.on("error", async (error) => {
1836
+ if (error.error && error.error.status === 402) {
1837
+ handleRestrictedMode(this);
1838
+ }
1839
+ });
1840
+ container.geoloniaMap = this;
1841
+ return this;
1842
+ }
1843
+ setStyle(style, options = {}) {
1844
+ if (style !== null && typeof style === "string") {
1845
+ style = getStyle(style, { lang: getLang(), apiKey: keyring.apiKey });
1846
+ }
1847
+ this.__styleExtensionLoadRequired = true;
1848
+ super.setStyle.call(this, style, options);
1849
+ return this;
1850
+ }
1851
+ remove() {
1852
+ const container = this.getContainer();
1853
+ super.remove.call(this);
1854
+ delete container.geoloniaMap;
1855
+ }
1856
+ loadImage(url, callback) {
1857
+ const promise = super.loadImage(url);
1858
+ if (callback) {
1859
+ loadImageCompatibility(promise, callback);
1860
+ } else {
1861
+ return promise;
1862
+ }
1863
+ }
1864
+ };
1865
+
1866
+ // src/version.ts
1867
+ var VERSION = "0.1.0";
1868
+ // Annotate the CommonJS export names for ESM import in node:
1869
+ 0 && (module.exports = {
1870
+ CustomAttributionControl,
1871
+ GeoloniaControl,
1872
+ GeoloniaMap,
1873
+ GeoloniaMarker,
1874
+ SimpleStyle,
1875
+ SimpleStyleVector,
1876
+ coreVersion,
1877
+ getLang,
1878
+ getStyle,
1879
+ isGeoloniaTilesHost,
1880
+ keyring
1881
+ });