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