@nextgis/leaflet-map-adapter 3.1.0 → 4.0.0-alpha.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.
@@ -1,477 +1,602 @@
1
- /** Bundle of @nextgis/leaflet-map-adapter; version: 3.1.0; author: NextGIS */
1
+ /** Bundle of @nextgis/leaflet-map-adapter; version: 4.0.0-alpha.1; author: NextGIS */
2
2
  var LeafletMapAdapter = (function () {
3
3
  'use strict';
4
4
 
5
- var domain;
6
-
7
- // This constructor is used to store event handlers. Instantiating this is
8
- // faster than explicitly calling `Object.create(null)` to get a "clean" empty
9
- // object (tested with v8 v4.9).
10
- function EventHandlers() {}
11
- EventHandlers.prototype = Object.create(null);
12
-
13
- function EventEmitter() {
14
- EventEmitter.init.call(this);
5
+ function getElement(el) {
6
+ if (typeof el === "string") {
7
+ let el_ = document.getElementById(el);
8
+ if (!el_) {
9
+ try {
10
+ el_ = document.querySelector(el);
11
+ } catch (e) {
12
+ }
13
+ }
14
+ return el_ || void 0;
15
+ }
16
+ return el;
15
17
  }
16
18
 
17
- // nodejs oddity
18
- // require('events') === require('events').EventEmitter
19
- EventEmitter.EventEmitter = EventEmitter;
20
-
21
- EventEmitter.usingDomains = false;
22
-
23
- EventEmitter.prototype.domain = undefined;
24
- EventEmitter.prototype._events = undefined;
25
- EventEmitter.prototype._maxListeners = undefined;
26
-
27
- // By default EventEmitters will print a warning if more than 10 listeners are
28
- // added to it. This is a useful default which helps finding memory leaks.
29
- EventEmitter.defaultMaxListeners = 10;
19
+ var __defProp$h = Object.defineProperty;
20
+ var __defProps$8 = Object.defineProperties;
21
+ var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
22
+ var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
23
+ var __hasOwnProp$c = Object.prototype.hasOwnProperty;
24
+ var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
25
+ var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
26
+ var __spreadValues$c = (a, b) => {
27
+ for (var prop in b || (b = {}))
28
+ if (__hasOwnProp$c.call(b, prop))
29
+ __defNormalProp$h(a, prop, b[prop]);
30
+ if (__getOwnPropSymbols$c)
31
+ for (var prop of __getOwnPropSymbols$c(b)) {
32
+ if (__propIsEnum$c.call(b, prop))
33
+ __defNormalProp$h(a, prop, b[prop]);
34
+ }
35
+ return a;
36
+ };
37
+ var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
38
+ const controlOptions = /* @__PURE__ */ new WeakMap();
39
+ function resolveControlOptions(options = {}) {
40
+ var _a;
41
+ return __spreadProps$8(__spreadValues$c({}, options), {
42
+ margin: (_a = options.margin) != null ? _a : options.bar
43
+ });
44
+ }
45
+ function setControlOptions(control, options = {}) {
46
+ controlOptions.set(control, resolveControlOptions(options));
47
+ }
48
+ function getControlOptions(control) {
49
+ return control ? controlOptions.get(control) : void 0;
50
+ }
30
51
 
31
- EventEmitter.init = function() {
32
- this.domain = null;
33
- if (EventEmitter.usingDomains) {
34
- // if there is an active domain, then attach to it.
35
- if (domain.active) ;
52
+ var __defProp$g = Object.defineProperty;
53
+ var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
54
+ var __publicField$a = (obj, key, value) => __defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
55
+ class ControlContainer {
56
+ constructor(opt = {}) {
57
+ __publicField$a(this, "classPrefix", "webmap");
58
+ __publicField$a(this, "addClass");
59
+ __publicField$a(this, "map");
60
+ __publicField$a(this, "wrapperClass");
61
+ __publicField$a(this, "ownsContainer");
62
+ __publicField$a(this, "_container");
63
+ __publicField$a(this, "_positionsContainers");
64
+ __publicField$a(this, "_targets", /* @__PURE__ */ new Set());
65
+ __publicField$a(this, "_idContainers", /* @__PURE__ */ new Map());
66
+ __publicField$a(this, "_pendingChildren", /* @__PURE__ */ new Map());
67
+ __publicField$a(this, "_orders", /* @__PURE__ */ new WeakMap());
68
+ __publicField$a(this, "_targetOptions", /* @__PURE__ */ new WeakMap());
69
+ __publicField$a(this, "_switchGroups", /* @__PURE__ */ new WeakMap());
70
+ __publicField$a(this, "_switchBindings", /* @__PURE__ */ new WeakMap());
71
+ this.classPrefix = opt.classPrefix || this.classPrefix;
72
+ this.addClass = opt.addClass;
73
+ this.map = opt.map;
74
+ this.wrapperClass = opt.wrapperClass;
75
+ const externalPositions = [
76
+ "top-right",
77
+ "top-left",
78
+ "bottom-right",
79
+ "bottom-left"
80
+ ];
81
+ const positionContainers = externalPositions.some(
82
+ (position) => {
83
+ var _a;
84
+ return !!((_a = opt.positionContainers) == null ? void 0 : _a[position]);
85
+ }
86
+ ) ? opt.positionContainers : void 0;
87
+ this.ownsContainer = !opt.container && !positionContainers;
88
+ const { element, positionsContainers } = this.createContainerElement(
89
+ opt.container,
90
+ positionContainers
91
+ );
92
+ this._container = element;
93
+ this._positionsContainers = positionsContainers;
36
94
  }
37
-
38
- if (!this._events || this._events === Object.getPrototypeOf(this)._events) {
39
- this._events = new EventHandlers();
40
- this._eventsCount = 0;
95
+ addTo(el) {
96
+ if (!this.ownsContainer) {
97
+ return this;
98
+ }
99
+ const el_ = getElement(el);
100
+ if (el_) {
101
+ el_.appendChild(this._container);
102
+ }
103
+ return this;
104
+ }
105
+ detach() {
106
+ if (!this.ownsContainer) {
107
+ Array.from(this._targets).forEach((target) => this.removeTarget(target));
108
+ this._pendingChildren.clear();
109
+ return;
110
+ }
111
+ const parent = this._container.parentElement;
112
+ if (parent) {
113
+ parent.removeChild(this._container);
114
+ }
115
+ }
116
+ getContainer() {
117
+ return this._container;
118
+ }
119
+ getPositionContainer(position) {
120
+ return this._positionsContainers[position];
121
+ }
122
+ newPositionContainer(position, order = 0, control) {
123
+ var _a;
124
+ const newContainer = document.createElement("div");
125
+ newContainer.className = `${this.classPrefix}-ctrl-wrapper` + (this.wrapperClass ? " " + this.wrapperClass : "");
126
+ if ((_a = getControlOptions(control)) == null ? void 0 : _a.margin) {
127
+ newContainer.classList.add(`${this.classPrefix}-ctrl-margin`);
128
+ }
129
+ this.append(newContainer, position, order, control);
130
+ return newContainer;
131
+ }
132
+ addControl(control, position, options = {}) {
133
+ const controlContainer = control.onAdd(this.map);
134
+ if (controlContainer instanceof HTMLElement) {
135
+ const target = this.newPositionContainer(
136
+ position,
137
+ options.order,
138
+ control
139
+ );
140
+ if (target) {
141
+ target.appendChild(controlContainer);
142
+ if (options.id) {
143
+ this.registerIDContainer(options.id, controlContainer, control);
144
+ }
145
+ return target;
146
+ }
147
+ }
148
+ }
149
+ append(element, position, order = 0, control) {
150
+ const node = this._normalizeElement(element);
151
+ if (!node) return;
152
+ const positionContainer = this._resolveTargetContainer(position);
153
+ if (positionContainer) {
154
+ this._insertSorted(positionContainer, node, order);
155
+ this._registerSwitchControl(node, control, positionContainer);
156
+ return positionContainer;
157
+ } else if (typeof position !== "string") {
158
+ this._appendPending(position.inside, node, order, control);
159
+ }
160
+ }
161
+ registerIDContainer(id, controlRoot, control) {
162
+ this._idContainers.set(id, controlRoot);
163
+ this._registerTargetOptions(controlRoot, control);
164
+ this._flushPending(id, controlRoot);
165
+ }
166
+ unregisterIDContainer(id) {
167
+ const controlRoot = this._idContainers.get(id);
168
+ if (controlRoot) {
169
+ this._targetOptions.delete(controlRoot);
170
+ }
171
+ this._idContainers.delete(id);
172
+ this._pendingChildren.delete(id);
173
+ }
174
+ removeTarget(target) {
175
+ const parent = target.parentElement;
176
+ if (parent) {
177
+ parent.removeChild(target);
178
+ }
179
+ this._unregisterSwitchControl(target);
180
+ this._removePending(target);
181
+ this._targets.delete(target);
182
+ }
183
+ createContainerElement(container, positionContainers) {
184
+ const element = container || document.createElement("div");
185
+ if (!container) {
186
+ element.className = `${this.classPrefix}-control-container` + (this.addClass ? " " + this.addClass : "");
187
+ }
188
+ const positionsContainers = {};
189
+ const positions = [
190
+ "top-right",
191
+ "top-left",
192
+ "bottom-right",
193
+ "bottom-left"
194
+ ];
195
+ positions.forEach((x) => {
196
+ const positionContainer = (positionContainers == null ? void 0 : positionContainers[x]) || this._createPositionContainer(x);
197
+ positionsContainers[x] = positionContainer;
198
+ if (!(positionContainers == null ? void 0 : positionContainers[x])) {
199
+ element.appendChild(positionContainer);
200
+ }
201
+ });
202
+ return { element, positionsContainers };
203
+ }
204
+ _createPositionContainer(position) {
205
+ const positionContainer = document.createElement("div");
206
+ positionContainer.className = `${this.classPrefix}-ctrl-${position}`;
207
+ return positionContainer;
208
+ }
209
+ _resolveTargetContainer(position) {
210
+ return typeof position === "string" ? this._positionsContainers[position] : this._idContainers.get(position.inside);
211
+ }
212
+ _normalizeElement(element) {
213
+ if (typeof element !== "string") {
214
+ return element;
215
+ }
216
+ const template = document.createElement("template");
217
+ template.innerHTML = element.trim();
218
+ return template.content.firstElementChild;
219
+ }
220
+ _insertSorted(positionContainer, element, order) {
221
+ this._orders.set(element, order);
222
+ element.style.order = String(order);
223
+ const isBottomPosition = this._isBottomPositionContainer(positionContainer);
224
+ const children = Array.from(positionContainer.children);
225
+ const before = children.find((child) => {
226
+ var _a;
227
+ if (child === element) {
228
+ return false;
229
+ }
230
+ const value = (_a = this._orders.get(child)) != null ? _a : Number.POSITIVE_INFINITY;
231
+ return isBottomPosition ? value <= order : value > order;
232
+ });
233
+ if (before) {
234
+ positionContainer.insertBefore(element, before);
235
+ } else if (element.parentElement === positionContainer) {
236
+ return;
237
+ } else {
238
+ positionContainer.appendChild(element);
239
+ }
240
+ this._targets.add(element);
241
+ }
242
+ _isBottomPositionContainer(element) {
243
+ return element === this._positionsContainers["bottom-left"] || element === this._positionsContainers["bottom-right"];
244
+ }
245
+ _appendPending(parentId, element, order, control) {
246
+ const parent = element.parentElement;
247
+ if (parent) {
248
+ parent.removeChild(element);
249
+ }
250
+ const pending = this._pendingChildren.get(parentId) || [];
251
+ pending.push({ element, order, control });
252
+ pending.sort((a, b) => a.order - b.order);
253
+ this._pendingChildren.set(parentId, pending);
254
+ this._targets.add(element);
255
+ }
256
+ _flushPending(parentId, target) {
257
+ const pending = this._pendingChildren.get(parentId);
258
+ if (!pending) return;
259
+ for (const { element, order, control } of pending) {
260
+ this._insertSorted(target, element, order);
261
+ this._registerSwitchControl(element, control, target);
262
+ }
263
+ this._pendingChildren.delete(parentId);
264
+ }
265
+ _removePending(target) {
266
+ this._pendingChildren.forEach((children, parentId) => {
267
+ const filtered = children.filter(({ element }) => element !== target);
268
+ if (filtered.length) {
269
+ this._pendingChildren.set(parentId, filtered);
270
+ } else {
271
+ this._pendingChildren.delete(parentId);
272
+ }
273
+ });
274
+ }
275
+ _registerSwitchControl(element, control, target) {
276
+ if (!this._isSwitchToggleControl(control)) return;
277
+ this._unregisterSwitchControl(element);
278
+ const groupName = typeof control.switch === "string" ? control.switch : "default";
279
+ const group = this._getSwitchGroup(target, groupName);
280
+ const hadDisableOnSecondClick = Object.prototype.hasOwnProperty.call(
281
+ control,
282
+ "disableOnSecondClick"
283
+ );
284
+ const previousDisableOnSecondClick = control.disableOnSecondClick;
285
+ const targetDisableOnSecondClick = control.disableOnSecondClick === void 0 ? this._getTargetDisableOnSecondClick(target) : void 0;
286
+ if (targetDisableOnSecondClick !== void 0) {
287
+ control.disableOnSecondClick = targetDisableOnSecondClick;
288
+ }
289
+ group.add(control);
290
+ const unsubscribe = control.onStatusChange((status) => {
291
+ if (status) {
292
+ this._disableSwitchSiblings(control, group);
293
+ }
294
+ });
295
+ this._switchBindings.set(element, {
296
+ control,
297
+ group,
298
+ unsubscribe,
299
+ hadDisableOnSecondClick,
300
+ previousDisableOnSecondClick
301
+ });
302
+ if (control.getStatus()) {
303
+ this._disableSwitchSiblings(control, group);
304
+ }
305
+ }
306
+ _unregisterSwitchControl(element) {
307
+ const binding = this._switchBindings.get(element);
308
+ if (binding) {
309
+ binding.unsubscribe();
310
+ binding.group.delete(binding.control);
311
+ if (binding.hadDisableOnSecondClick) {
312
+ binding.control.disableOnSecondClick = binding.previousDisableOnSecondClick;
313
+ } else {
314
+ delete binding.control.disableOnSecondClick;
315
+ }
316
+ this._switchBindings.delete(element);
317
+ }
318
+ Array.from(element.children).forEach((child) => {
319
+ if (child instanceof HTMLElement) {
320
+ this._unregisterSwitchControl(child);
321
+ }
322
+ });
323
+ }
324
+ _getSwitchGroup(target, groupName) {
325
+ let targetGroups = this._switchGroups.get(target);
326
+ if (!targetGroups) {
327
+ targetGroups = /* @__PURE__ */ new Map();
328
+ this._switchGroups.set(target, targetGroups);
329
+ }
330
+ let group = targetGroups.get(groupName);
331
+ if (!group) {
332
+ group = /* @__PURE__ */ new Set();
333
+ targetGroups.set(groupName, group);
334
+ }
335
+ return group;
336
+ }
337
+ _disableSwitchSiblings(activeControl, group) {
338
+ group.forEach((control) => {
339
+ if (control !== activeControl && control.getStatus()) {
340
+ control.onClick(false);
341
+ }
342
+ });
343
+ }
344
+ _getTargetDisableOnSecondClick(target) {
345
+ var _a;
346
+ return (_a = this._targetOptions.get(target)) == null ? void 0 : _a.disableOnSecondClick;
347
+ }
348
+ _isSwitchToggleControl(control) {
349
+ const toggle = control;
350
+ return !!((toggle == null ? void 0 : toggle.switch) && typeof toggle.onStatusChange === "function" && typeof toggle.getStatus === "function" && typeof toggle.onClick === "function");
351
+ }
352
+ _registerTargetOptions(target, control) {
353
+ const options = getControlOptions(control) || getControlOptions(target);
354
+ if (options) {
355
+ this._targetOptions.set(target, options);
356
+ } else {
357
+ this._targetOptions.delete(target);
358
+ }
41
359
  }
42
-
43
- this._maxListeners = this._maxListeners || undefined;
44
- };
45
-
46
- // Obviously not all Emitters should be limited to 10. This function allows
47
- // that to be increased. Set to zero for unlimited.
48
- EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
49
- if (typeof n !== 'number' || n < 0 || isNaN(n))
50
- throw new TypeError('"n" argument must be a positive number');
51
- this._maxListeners = n;
52
- return this;
53
- };
54
-
55
- function $getMaxListeners(that) {
56
- if (that._maxListeners === undefined)
57
- return EventEmitter.defaultMaxListeners;
58
- return that._maxListeners;
59
360
  }
60
361
 
61
- EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
62
- return $getMaxListeners(this);
63
- };
64
-
65
- // These standalone emit* functions are used to optimize calling of event
66
- // handlers for fast cases because emit() itself often has a variable number of
67
- // arguments and can be deoptimized because of that. These functions always have
68
- // the same number of arguments and thus do not get deoptimized, so the code
69
- // inside them can execute faster.
70
- function emitNone(handler, isFn, self) {
71
- if (isFn)
72
- handler.call(self);
73
- else {
74
- var len = handler.length;
75
- var listeners = arrayClone(handler, len);
76
- for (var i = 0; i < len; ++i)
77
- listeners[i].call(self);
362
+ const STOP_PROPAGATION_EVENTS = [
363
+ "wheel",
364
+ "click",
365
+ "mouseup",
366
+ "touchend",
367
+ "dblclick",
368
+ "pointerup",
369
+ "mousedown",
370
+ "touchstart",
371
+ "pointerdown"
372
+ ];
373
+ function addClasses(element, classes) {
374
+ if (classes) {
375
+ classes.split(" ").filter(Boolean).forEach((x) => element.classList.add(x));
78
376
  }
79
377
  }
80
- function emitOne(handler, isFn, self, arg1) {
81
- if (isFn)
82
- handler.call(self, arg1);
83
- else {
84
- var len = handler.length;
85
- var listeners = arrayClone(handler, len);
86
- for (var i = 0; i < len; ++i)
87
- listeners[i].call(self, arg1);
378
+ function removeElement(element) {
379
+ if (element == null ? void 0 : element.parentNode) {
380
+ element.parentNode.removeChild(element);
88
381
  }
89
382
  }
90
- function emitTwo(handler, isFn, self, arg1, arg2) {
91
- if (isFn)
92
- handler.call(self, arg1, arg2);
93
- else {
94
- var len = handler.length;
95
- var listeners = arrayClone(handler, len);
96
- for (var i = 0; i < len; ++i)
97
- listeners[i].call(self, arg1, arg2);
383
+ function stopPropagation(event) {
384
+ event.stopPropagation();
385
+ }
386
+ function preventMapEventPropagation(element) {
387
+ STOP_PROPAGATION_EVENTS.forEach((eventName) => {
388
+ element.addEventListener(eventName, stopPropagation);
389
+ });
390
+ }
391
+ function getAlignValue(align) {
392
+ if (align === "start") return "flex-start";
393
+ if (align === "end") return "flex-end";
394
+ return align;
395
+ }
396
+ function isZeroGap(gap) {
397
+ if (typeof gap === "number") {
398
+ return gap === 0;
98
399
  }
400
+ if (typeof gap === "string") {
401
+ return gap.trim().split(/\s+/).every((x) => /^0(?:\.0+)?(?:[a-z%]+)?$/i.test(x));
402
+ }
403
+ return false;
99
404
  }
100
- function emitThree(handler, isFn, self, arg1, arg2, arg3) {
101
- if (isFn)
102
- handler.call(self, arg1, arg2, arg3);
103
- else {
104
- var len = handler.length;
105
- var listeners = arrayClone(handler, len);
106
- for (var i = 0; i < len; ++i)
107
- listeners[i].call(self, arg1, arg2, arg3);
405
+ function createControlContainer(options = {}) {
406
+ const resolvedOptions = resolveControlOptions(options);
407
+ const element = document.createElement("div");
408
+ element.className = "webmap-ctrl";
409
+ if (resolvedOptions.bar) {
410
+ element.classList.add("webmap-ctrl-group");
411
+ }
412
+ if (resolvedOptions.margin) {
413
+ element.classList.add("webmap-ctrl-margin");
414
+ }
415
+ const orientation = resolvedOptions.orientation || resolvedOptions.direction;
416
+ if (orientation) {
417
+ element.classList.add(`webmap-ctrl-${orientation}`);
108
418
  }
419
+ if (resolvedOptions.gap !== void 0) {
420
+ const gap = typeof resolvedOptions.gap === "number" ? `${resolvedOptions.gap}px` : resolvedOptions.gap;
421
+ element.style.setProperty("--webmap-ctrl-gap", gap);
422
+ if (isZeroGap(resolvedOptions.gap)) {
423
+ element.classList.add("webmap-ctrl-gapless");
424
+ }
425
+ }
426
+ const align = getAlignValue(resolvedOptions.align);
427
+ if (align) {
428
+ element.style.setProperty("--webmap-ctrl-align", align);
429
+ }
430
+ addClasses(element, resolvedOptions.addClass);
431
+ preventMapEventPropagation(element);
432
+ return element;
109
433
  }
110
-
111
- function emitMany(handler, isFn, self, args) {
112
- if (isFn)
113
- handler.apply(self, args);
114
- else {
115
- var len = handler.length;
116
- var listeners = arrayClone(handler, len);
117
- for (var i = 0; i < len; ++i)
118
- listeners[i].apply(self, args);
434
+ function appendHtml(element, html) {
435
+ if (html instanceof HTMLElement) {
436
+ element.appendChild(html);
437
+ } else if (typeof html === "string") {
438
+ element.innerHTML = html;
119
439
  }
120
440
  }
121
-
122
- EventEmitter.prototype.emit = function emit(type) {
123
- var er, handler, len, args, i, events, domain;
124
- var doError = (type === 'error');
125
-
126
- events = this._events;
127
- if (events)
128
- doError = (doError && events.error == null);
129
- else if (!doError)
130
- return false;
131
-
132
- domain = this.domain;
133
-
134
- // If there is no 'error' event listener then throw.
135
- if (doError) {
136
- er = arguments[1];
137
- if (domain) {
138
- if (!er)
139
- er = new Error('Uncaught, unspecified "error" event');
140
- er.domainEmitter = this;
141
- er.domain = domain;
142
- er.domainThrown = false;
143
- domain.emit('error', er);
144
- } else if (er instanceof Error) {
145
- throw er; // Unhandled 'error' event
146
- } else {
147
- // At least give some kind of context to the user
148
- var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
149
- err.context = er;
150
- throw err;
441
+ function createControlElement(control, options = {}, map) {
442
+ const element = createControlContainer(options);
443
+ setControlOptions(element, options);
444
+ const content = control.onAdd(map);
445
+ if (content) {
446
+ element.appendChild(content);
447
+ }
448
+ return element;
449
+ }
450
+ function createButtonControlContent(options) {
451
+ let button;
452
+ const onClick = (event) => {
453
+ event.preventDefault();
454
+ event.stopPropagation();
455
+ options.onClick();
456
+ };
457
+ const buttonControl = {
458
+ onAdd() {
459
+ button = document.createElement("button");
460
+ button.type = "button";
461
+ button.className = "webmap-ctrl-button";
462
+ addClasses(button, options.addClass);
463
+ if (options.title) {
464
+ button.title = options.title;
465
+ button.setAttribute("aria-label", options.title);
466
+ }
467
+ appendHtml(button, options.html);
468
+ button.addEventListener("click", onClick);
469
+ return button;
470
+ },
471
+ onRemove() {
472
+ if (button) {
473
+ button.removeEventListener("click", onClick);
474
+ removeElement(button);
475
+ button = void 0;
476
+ }
477
+ },
478
+ getContainer() {
479
+ return button;
151
480
  }
152
- return false;
481
+ };
482
+ buttonControl.remove = () => {
483
+ buttonControl.onRemove();
484
+ };
485
+ return buttonControl;
486
+ }
487
+ function createToggleControlContent(options) {
488
+ const link = document.createElement("div");
489
+ const statusListeners = /* @__PURE__ */ new Set();
490
+ let status = false;
491
+ if (options.getStatus) {
492
+ status = options.getStatus();
493
+ } else if (options.status) {
494
+ status = options.status;
153
495
  }
154
-
155
- handler = events[type];
156
-
157
- if (!handler)
158
- return false;
159
-
160
- var isFn = typeof handler === 'function';
161
- len = arguments.length;
162
- switch (len) {
163
- // fast cases
164
- case 1:
165
- emitNone(handler, isFn, this);
166
- break;
167
- case 2:
168
- emitOne(handler, isFn, this, arguments[1]);
169
- break;
170
- case 3:
171
- emitTwo(handler, isFn, this, arguments[1], arguments[2]);
172
- break;
173
- case 4:
174
- emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
175
- break;
176
- // slower
177
- default:
178
- args = new Array(len - 1);
179
- for (i = 1; i < len; i++)
180
- args[i - 1] = arguments[i];
181
- emitMany(handler, isFn, this, args);
496
+ const title = options.title || "";
497
+ const html = options.html;
498
+ function notifyStatusChange(control) {
499
+ statusListeners.forEach((listener) => listener(status, control));
182
500
  }
183
-
184
- return true;
185
- };
186
-
187
- function _addListener(target, type, listener, prepend) {
188
- var m;
189
- var events;
190
- var existing;
191
-
192
- if (typeof listener !== 'function')
193
- throw new TypeError('"listener" argument must be a function');
194
-
195
- events = target._events;
196
- if (!events) {
197
- events = target._events = new EventHandlers();
198
- target._eventsCount = 0;
199
- } else {
200
- // To avoid recursion in the case that type === "newListener"! Before
201
- // adding it to the listeners, first emit "newListener".
202
- if (events.newListener) {
203
- target.emit('newListener', type,
204
- listener.listener ? listener.listener : listener);
205
-
206
- // Re-assign `events` because a newListener handler could have caused the
207
- // this._events to be assigned to a new object
208
- events = target._events;
501
+ function setTitle() {
502
+ if (title) {
503
+ if (typeof title === "string") {
504
+ link.title = title;
505
+ } else {
506
+ link.title = status ? title.on : title.off;
507
+ }
508
+ link.setAttribute("aria-label", link.title);
209
509
  }
210
- existing = events[type];
211
510
  }
212
-
213
- if (!existing) {
214
- // Optimize the case of one listener. Don't need the extra array object.
215
- existing = events[type] = listener;
216
- ++target._eventsCount;
217
- } else {
218
- if (typeof existing === 'function') {
219
- // Adding the second element, need to change to array.
220
- existing = events[type] = prepend ? [listener, existing] :
221
- [existing, listener];
222
- } else {
223
- // If we've already got an array, just append.
224
- if (prepend) {
225
- existing.unshift(listener);
511
+ function setHtml() {
512
+ if (html) {
513
+ link.innerHTML = "";
514
+ if (typeof html === "string" || html instanceof HTMLElement) {
515
+ appendHtml(link, html);
226
516
  } else {
227
- existing.push(listener);
517
+ appendHtml(link, status ? html.on : html.off);
228
518
  }
229
519
  }
230
-
231
- // Check for listener leak
232
- if (!existing.warned) {
233
- m = $getMaxListeners(target);
234
- if (m && m > 0 && existing.length > m) {
235
- existing.warned = true;
236
- var w = new Error('Possible EventEmitter memory leak detected. ' +
237
- existing.length + ' ' + type + ' listeners added. ' +
238
- 'Use emitter.setMaxListeners() to increase limit');
239
- w.name = 'MaxListenersExceededWarning';
240
- w.emitter = target;
241
- w.type = type;
242
- w.count = existing.length;
243
- emitWarning(w);
520
+ }
521
+ function setClasses(classes, impact) {
522
+ classes.split(" ").filter(Boolean).forEach((x) => {
523
+ if (impact) {
524
+ link.classList.add(x);
525
+ } else {
526
+ link.classList.remove(x);
244
527
  }
245
- }
528
+ });
246
529
  }
247
-
248
- return target;
249
- }
250
- function emitWarning(e) {
251
- typeof console.warn === 'function' ? console.warn(e) : console.log(e);
252
- }
253
- EventEmitter.prototype.addListener = function addListener(type, listener) {
254
- return _addListener(this, type, listener, false);
255
- };
256
-
257
- EventEmitter.prototype.on = EventEmitter.prototype.addListener;
258
-
259
- EventEmitter.prototype.prependListener =
260
- function prependListener(type, listener) {
261
- return _addListener(this, type, listener, true);
262
- };
263
-
264
- function _onceWrap(target, type, listener) {
265
- var fired = false;
266
- function g() {
267
- target.removeListener(type, g);
268
- if (!fired) {
269
- fired = true;
270
- listener.apply(target, arguments);
530
+ function setStatusClasses() {
531
+ if (options.addClassOn) {
532
+ setClasses(options.addClassOn, status);
533
+ }
534
+ if (options.addClassOff) {
535
+ setClasses(options.addClassOff, !status);
271
536
  }
272
537
  }
273
- g.listener = listener;
274
- return g;
275
- }
276
-
277
- EventEmitter.prototype.once = function once(type, listener) {
278
- if (typeof listener !== 'function')
279
- throw new TypeError('"listener" argument must be a function');
280
- this.on(type, _onceWrap(this, type, listener));
281
- return this;
282
- };
283
-
284
- EventEmitter.prototype.prependOnceListener =
285
- function prependOnceListener(type, listener) {
286
- if (typeof listener !== 'function')
287
- throw new TypeError('"listener" argument must be a function');
288
- this.prependListener(type, _onceWrap(this, type, listener));
289
- return this;
290
- };
291
-
292
- // emits a 'removeListener' event iff the listener was removed
293
- EventEmitter.prototype.removeListener =
294
- function removeListener(type, listener) {
295
- var list, events, position, i, originalListener;
296
-
297
- if (typeof listener !== 'function')
298
- throw new TypeError('"listener" argument must be a function');
299
-
300
- events = this._events;
301
- if (!events)
302
- return this;
303
-
304
- list = events[type];
305
- if (!list)
306
- return this;
307
-
308
- if (list === listener || (list.listener && list.listener === listener)) {
309
- if (--this._eventsCount === 0)
310
- this._events = new EventHandlers();
311
- else {
312
- delete events[type];
313
- if (events.removeListener)
314
- this.emit('removeListener', type, list.listener || listener);
315
- }
316
- } else if (typeof list !== 'function') {
317
- position = -1;
318
-
319
- for (i = list.length; i-- > 0;) {
320
- if (list[i] === listener ||
321
- (list[i].listener && list[i].listener === listener)) {
322
- originalListener = list[i].listener;
323
- position = i;
324
- break;
325
- }
326
- }
327
-
328
- if (position < 0)
329
- return this;
330
-
331
- if (list.length === 1) {
332
- list[0] = undefined;
333
- if (--this._eventsCount === 0) {
334
- this._events = new EventHandlers();
335
- return this;
336
- } else {
337
- delete events[type];
338
- }
339
- } else {
340
- spliceOne(list, position);
341
- }
342
-
343
- if (events.removeListener)
344
- this.emit('removeListener', type, originalListener || listener);
345
- }
346
-
347
- return this;
348
- };
349
-
350
- // Alias for removeListener added in NodeJS 10.0
351
- // https://nodejs.org/api/events.html#events_emitter_off_eventname_listener
352
- EventEmitter.prototype.off = function(type, listener){
353
- return this.removeListener(type, listener);
354
- };
355
-
356
- EventEmitter.prototype.removeAllListeners =
357
- function removeAllListeners(type) {
358
- var listeners, events;
359
-
360
- events = this._events;
361
- if (!events)
362
- return this;
363
-
364
- // not listening for removeListener, no need to emit
365
- if (!events.removeListener) {
366
- if (arguments.length === 0) {
367
- this._events = new EventHandlers();
368
- this._eventsCount = 0;
369
- } else if (events[type]) {
370
- if (--this._eventsCount === 0)
371
- this._events = new EventHandlers();
372
- else
373
- delete events[type];
374
- }
375
- return this;
538
+ setTitle();
539
+ setHtml();
540
+ if (options.addClass) {
541
+ setClasses(options.addClass, true);
542
+ }
543
+ setStatusClasses();
544
+ const changeStatus = (status_) => {
545
+ if (status_ !== void 0) {
546
+ status = status_;
547
+ }
548
+ setHtml();
549
+ setTitle();
550
+ setStatusClasses();
551
+ };
552
+ const getStatus = () => status;
553
+ const onClick = (status_) => {
554
+ if (status_ === void 0 && status && buttonControl.disableOnSecondClick) {
555
+ return;
556
+ }
557
+ const previousStatus = status;
558
+ status = status_ !== void 0 ? status_ : !status;
559
+ if (options.onClick) {
560
+ let afterClick;
561
+ try {
562
+ afterClick = options.onClick(status);
563
+ } catch (er) {
564
+ status = previousStatus;
565
+ changeStatus();
566
+ throw er;
376
567
  }
377
-
378
- // emit removeListener for all listeners on all events
379
- if (arguments.length === 0) {
380
- var keys = Object.keys(events);
381
- for (var i = 0, key; i < keys.length; ++i) {
382
- key = keys[i];
383
- if (key === 'removeListener') continue;
384
- this.removeAllListeners(key);
568
+ Promise.resolve(afterClick).then(() => {
569
+ changeStatus();
570
+ if (previousStatus !== status) {
571
+ notifyStatusChange(buttonControl);
385
572
  }
386
- this.removeAllListeners('removeListener');
387
- this._events = new EventHandlers();
388
- this._eventsCount = 0;
389
- return this;
390
- }
391
-
392
- listeners = events[type];
393
-
394
- if (typeof listeners === 'function') {
395
- this.removeListener(type, listeners);
396
- } else if (listeners) {
397
- // LIFO order
398
- do {
399
- this.removeListener(type, listeners[listeners.length - 1]);
400
- } while (listeners[0]);
573
+ }).catch(() => {
574
+ status = previousStatus;
575
+ changeStatus();
576
+ });
577
+ } else {
578
+ changeStatus();
579
+ if (previousStatus !== status) {
580
+ notifyStatusChange(buttonControl);
401
581
  }
402
-
403
- return this;
404
- };
405
-
406
- EventEmitter.prototype.listeners = function listeners(type) {
407
- var evlistener;
408
- var ret;
409
- var events = this._events;
410
-
411
- if (!events)
412
- ret = [];
413
- else {
414
- evlistener = events[type];
415
- if (!evlistener)
416
- ret = [];
417
- else if (typeof evlistener === 'function')
418
- ret = [evlistener.listener || evlistener];
419
- else
420
- ret = unwrapListeners(evlistener);
421
- }
422
-
423
- return ret;
424
- };
425
-
426
- EventEmitter.listenerCount = function(emitter, type) {
427
- if (typeof emitter.listenerCount === 'function') {
428
- return emitter.listenerCount(type);
429
- } else {
430
- return listenerCount.call(emitter, type);
431
- }
432
- };
433
-
434
- EventEmitter.prototype.listenerCount = listenerCount;
435
- function listenerCount(type) {
436
- var events = this._events;
437
-
438
- if (events) {
439
- var evlistener = events[type];
440
-
441
- if (typeof evlistener === 'function') {
442
- return 1;
443
- } else if (evlistener) {
444
- return evlistener.length;
445
- }
446
- }
447
-
448
- return 0;
449
- }
450
-
451
- EventEmitter.prototype.eventNames = function eventNames() {
452
- return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
453
- };
454
-
455
- // About 1.5x faster than the two-arg version of Array#splice().
456
- function spliceOne(list, index) {
457
- for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
458
- list[i] = list[k];
459
- list.pop();
460
- }
461
-
462
- function arrayClone(arr, i) {
463
- var copy = new Array(i);
464
- while (i--)
465
- copy[i] = arr[i];
466
- return copy;
467
- }
468
-
469
- function unwrapListeners(arr) {
470
- var ret = new Array(arr.length);
471
- for (var i = 0; i < ret.length; ++i) {
472
- ret[i] = arr[i].listener || arr[i];
582
+ }
583
+ };
584
+ const buttonControl = createButtonControlContent({
585
+ html: link,
586
+ onClick
587
+ });
588
+ buttonControl.onClick = onClick;
589
+ buttonControl.changeStatus = changeStatus;
590
+ buttonControl.getStatus = getStatus;
591
+ buttonControl.switch = options.switch;
592
+ if (options.disableOnSecondClick !== void 0) {
593
+ buttonControl.disableOnSecondClick = options.disableOnSecondClick;
473
594
  }
474
- return ret;
595
+ buttonControl.onStatusChange = (listener) => {
596
+ statusListeners.add(listener);
597
+ return () => statusListeners.delete(listener);
598
+ };
599
+ return buttonControl;
475
600
  }
476
601
 
477
602
  var leafletSrc$1 = {exports: {}};
@@ -14188,365 +14313,1019 @@ var LeafletMapAdapter = (function () {
14188
14313
  });
14189
14314
 
14190
14315
  // @section Handlers
14191
- // @property scrollWheelZoom: Handler
14192
- // Scroll wheel zoom handler.
14193
- Map.addInitHook('addHandler', 'scrollWheelZoom', ScrollWheelZoom);
14316
+ // @property scrollWheelZoom: Handler
14317
+ // Scroll wheel zoom handler.
14318
+ Map.addInitHook('addHandler', 'scrollWheelZoom', ScrollWheelZoom);
14319
+
14320
+ /*
14321
+ * L.Map.Tap is used to enable mobile hacks like quick taps and long hold.
14322
+ */
14323
+
14324
+ // @namespace Map
14325
+ // @section Interaction Options
14326
+ Map.mergeOptions({
14327
+ // @section Touch interaction options
14328
+ // @option tap: Boolean = true
14329
+ // Enables mobile hacks for supporting instant taps (fixing 200ms click
14330
+ // delay on iOS/Android) and touch holds (fired as `contextmenu` events).
14331
+ tap: true,
14332
+
14333
+ // @option tapTolerance: Number = 15
14334
+ // The max number of pixels a user can shift his finger during touch
14335
+ // for it to be considered a valid tap.
14336
+ tapTolerance: 15
14337
+ });
14338
+
14339
+ var Tap = Handler.extend({
14340
+ addHooks: function () {
14341
+ on(this._map._container, 'touchstart', this._onDown, this);
14342
+ },
14343
+
14344
+ removeHooks: function () {
14345
+ off(this._map._container, 'touchstart', this._onDown, this);
14346
+ },
14347
+
14348
+ _onDown: function (e) {
14349
+ if (!e.touches) { return; }
14350
+
14351
+ preventDefault(e);
14352
+
14353
+ this._fireClick = true;
14354
+
14355
+ // don't simulate click or track longpress if more than 1 touch
14356
+ if (e.touches.length > 1) {
14357
+ this._fireClick = false;
14358
+ clearTimeout(this._holdTimeout);
14359
+ return;
14360
+ }
14361
+
14362
+ var first = e.touches[0],
14363
+ el = first.target;
14364
+
14365
+ this._startPos = this._newPos = new Point(first.clientX, first.clientY);
14366
+
14367
+ // if touching a link, highlight it
14368
+ if (el.tagName && el.tagName.toLowerCase() === 'a') {
14369
+ addClass(el, 'leaflet-active');
14370
+ }
14371
+
14372
+ // simulate long hold but setting a timeout
14373
+ this._holdTimeout = setTimeout(bind(function () {
14374
+ if (this._isTapValid()) {
14375
+ this._fireClick = false;
14376
+ this._onUp();
14377
+ this._simulateEvent('contextmenu', first);
14378
+ }
14379
+ }, this), 1000);
14380
+
14381
+ this._simulateEvent('mousedown', first);
14382
+
14383
+ on(document, {
14384
+ touchmove: this._onMove,
14385
+ touchend: this._onUp
14386
+ }, this);
14387
+ },
14388
+
14389
+ _onUp: function (e) {
14390
+ clearTimeout(this._holdTimeout);
14391
+
14392
+ off(document, {
14393
+ touchmove: this._onMove,
14394
+ touchend: this._onUp
14395
+ }, this);
14396
+
14397
+ if (this._fireClick && e && e.changedTouches) {
14398
+
14399
+ var first = e.changedTouches[0],
14400
+ el = first.target;
14401
+
14402
+ if (el && el.tagName && el.tagName.toLowerCase() === 'a') {
14403
+ removeClass(el, 'leaflet-active');
14404
+ }
14405
+
14406
+ this._simulateEvent('mouseup', first);
14407
+
14408
+ // simulate click if the touch didn't move too much
14409
+ if (this._isTapValid()) {
14410
+ this._simulateEvent('click', first);
14411
+ }
14412
+ }
14413
+ },
14414
+
14415
+ _isTapValid: function () {
14416
+ return this._newPos.distanceTo(this._startPos) <= this._map.options.tapTolerance;
14417
+ },
14418
+
14419
+ _onMove: function (e) {
14420
+ var first = e.touches[0];
14421
+ this._newPos = new Point(first.clientX, first.clientY);
14422
+ this._simulateEvent('mousemove', first);
14423
+ },
14424
+
14425
+ _simulateEvent: function (type, e) {
14426
+ var simulatedEvent = document.createEvent('MouseEvents');
14427
+
14428
+ simulatedEvent._simulated = true;
14429
+ e.target._simulatedClick = true;
14430
+
14431
+ simulatedEvent.initMouseEvent(
14432
+ type, true, true, window, 1,
14433
+ e.screenX, e.screenY,
14434
+ e.clientX, e.clientY,
14435
+ false, false, false, false, 0, null);
14436
+
14437
+ e.target.dispatchEvent(simulatedEvent);
14438
+ }
14439
+ });
14440
+
14441
+ // @section Handlers
14442
+ // @property tap: Handler
14443
+ // Mobile touch hacks (quick tap and touch hold) handler.
14444
+ if (touch && (!pointer || safari)) {
14445
+ Map.addInitHook('addHandler', 'tap', Tap);
14446
+ }
14447
+
14448
+ /*
14449
+ * L.Handler.TouchZoom is used by L.Map to add pinch zoom on supported mobile browsers.
14450
+ */
14451
+
14452
+ // @namespace Map
14453
+ // @section Interaction Options
14454
+ Map.mergeOptions({
14455
+ // @section Touch interaction options
14456
+ // @option touchZoom: Boolean|String = *
14457
+ // Whether the map can be zoomed by touch-dragging with two fingers. If
14458
+ // passed `'center'`, it will zoom to the center of the view regardless of
14459
+ // where the touch events (fingers) were. Enabled for touch-capable web
14460
+ // browsers except for old Androids.
14461
+ touchZoom: touch && !android23,
14462
+
14463
+ // @option bounceAtZoomLimits: Boolean = true
14464
+ // Set it to false if you don't want the map to zoom beyond min/max zoom
14465
+ // and then bounce back when pinch-zooming.
14466
+ bounceAtZoomLimits: true
14467
+ });
14468
+
14469
+ var TouchZoom = Handler.extend({
14470
+ addHooks: function () {
14471
+ addClass(this._map._container, 'leaflet-touch-zoom');
14472
+ on(this._map._container, 'touchstart', this._onTouchStart, this);
14473
+ },
14474
+
14475
+ removeHooks: function () {
14476
+ removeClass(this._map._container, 'leaflet-touch-zoom');
14477
+ off(this._map._container, 'touchstart', this._onTouchStart, this);
14478
+ },
14479
+
14480
+ _onTouchStart: function (e) {
14481
+ var map = this._map;
14482
+ if (!e.touches || e.touches.length !== 2 || map._animatingZoom || this._zooming) { return; }
14483
+
14484
+ var p1 = map.mouseEventToContainerPoint(e.touches[0]),
14485
+ p2 = map.mouseEventToContainerPoint(e.touches[1]);
14486
+
14487
+ this._centerPoint = map.getSize()._divideBy(2);
14488
+ this._startLatLng = map.containerPointToLatLng(this._centerPoint);
14489
+ if (map.options.touchZoom !== 'center') {
14490
+ this._pinchStartLatLng = map.containerPointToLatLng(p1.add(p2)._divideBy(2));
14491
+ }
14492
+
14493
+ this._startDist = p1.distanceTo(p2);
14494
+ this._startZoom = map.getZoom();
14495
+
14496
+ this._moved = false;
14497
+ this._zooming = true;
14498
+
14499
+ map._stop();
14500
+
14501
+ on(document, 'touchmove', this._onTouchMove, this);
14502
+ on(document, 'touchend', this._onTouchEnd, this);
14503
+
14504
+ preventDefault(e);
14505
+ },
14506
+
14507
+ _onTouchMove: function (e) {
14508
+ if (!e.touches || e.touches.length !== 2 || !this._zooming) { return; }
14509
+
14510
+ var map = this._map,
14511
+ p1 = map.mouseEventToContainerPoint(e.touches[0]),
14512
+ p2 = map.mouseEventToContainerPoint(e.touches[1]),
14513
+ scale = p1.distanceTo(p2) / this._startDist;
14514
+
14515
+ this._zoom = map.getScaleZoom(scale, this._startZoom);
14516
+
14517
+ if (!map.options.bounceAtZoomLimits && (
14518
+ (this._zoom < map.getMinZoom() && scale < 1) ||
14519
+ (this._zoom > map.getMaxZoom() && scale > 1))) {
14520
+ this._zoom = map._limitZoom(this._zoom);
14521
+ }
14522
+
14523
+ if (map.options.touchZoom === 'center') {
14524
+ this._center = this._startLatLng;
14525
+ if (scale === 1) { return; }
14526
+ } else {
14527
+ // Get delta from pinch to center, so centerLatLng is delta applied to initial pinchLatLng
14528
+ var delta = p1._add(p2)._divideBy(2)._subtract(this._centerPoint);
14529
+ if (scale === 1 && delta.x === 0 && delta.y === 0) { return; }
14530
+ this._center = map.unproject(map.project(this._pinchStartLatLng, this._zoom).subtract(delta), this._zoom);
14531
+ }
14532
+
14533
+ if (!this._moved) {
14534
+ map._moveStart(true, false);
14535
+ this._moved = true;
14536
+ }
14537
+
14538
+ cancelAnimFrame(this._animRequest);
14539
+
14540
+ var moveFn = bind(map._move, map, this._center, this._zoom, {pinch: true, round: false});
14541
+ this._animRequest = requestAnimFrame(moveFn, this, true);
14542
+
14543
+ preventDefault(e);
14544
+ },
14545
+
14546
+ _onTouchEnd: function () {
14547
+ if (!this._moved || !this._zooming) {
14548
+ this._zooming = false;
14549
+ return;
14550
+ }
14551
+
14552
+ this._zooming = false;
14553
+ cancelAnimFrame(this._animRequest);
14554
+
14555
+ off(document, 'touchmove', this._onTouchMove, this);
14556
+ off(document, 'touchend', this._onTouchEnd, this);
14557
+
14558
+ // Pinch updates GridLayers' levels only when zoomSnap is off, so zoomSnap becomes noUpdate.
14559
+ if (this._map.options.zoomAnimation) {
14560
+ this._map._animateZoom(this._center, this._map._limitZoom(this._zoom), true, this._map.options.zoomSnap);
14561
+ } else {
14562
+ this._map._resetView(this._center, this._map._limitZoom(this._zoom));
14563
+ }
14564
+ }
14565
+ });
14566
+
14567
+ // @section Handlers
14568
+ // @property touchZoom: Handler
14569
+ // Touch zoom handler.
14570
+ Map.addInitHook('addHandler', 'touchZoom', TouchZoom);
14194
14571
 
14195
- /*
14196
- * L.Map.Tap is used to enable mobile hacks like quick taps and long hold.
14197
- */
14572
+ Map.BoxZoom = BoxZoom;
14573
+ Map.DoubleClickZoom = DoubleClickZoom;
14574
+ Map.Drag = Drag;
14575
+ Map.Keyboard = Keyboard;
14576
+ Map.ScrollWheelZoom = ScrollWheelZoom;
14577
+ Map.Tap = Tap;
14578
+ Map.TouchZoom = TouchZoom;
14198
14579
 
14199
- // @namespace Map
14200
- // @section Interaction Options
14201
- Map.mergeOptions({
14202
- // @section Touch interaction options
14203
- // @option tap: Boolean = true
14204
- // Enables mobile hacks for supporting instant taps (fixing 200ms click
14205
- // delay on iOS/Android) and touch holds (fired as `contextmenu` events).
14206
- tap: true,
14580
+ exports.version = version;
14581
+ exports.Control = Control;
14582
+ exports.control = control;
14583
+ exports.Browser = Browser;
14584
+ exports.Evented = Evented;
14585
+ exports.Mixin = Mixin;
14586
+ exports.Util = Util;
14587
+ exports.Class = Class;
14588
+ exports.Handler = Handler;
14589
+ exports.extend = extend;
14590
+ exports.bind = bind;
14591
+ exports.stamp = stamp;
14592
+ exports.setOptions = setOptions;
14593
+ exports.DomEvent = DomEvent;
14594
+ exports.DomUtil = DomUtil;
14595
+ exports.PosAnimation = PosAnimation;
14596
+ exports.Draggable = Draggable;
14597
+ exports.LineUtil = LineUtil;
14598
+ exports.PolyUtil = PolyUtil;
14599
+ exports.Point = Point;
14600
+ exports.point = toPoint;
14601
+ exports.Bounds = Bounds;
14602
+ exports.bounds = toBounds;
14603
+ exports.Transformation = Transformation;
14604
+ exports.transformation = toTransformation;
14605
+ exports.Projection = index;
14606
+ exports.LatLng = LatLng;
14607
+ exports.latLng = toLatLng;
14608
+ exports.LatLngBounds = LatLngBounds;
14609
+ exports.latLngBounds = toLatLngBounds;
14610
+ exports.CRS = CRS;
14611
+ exports.GeoJSON = GeoJSON;
14612
+ exports.geoJSON = geoJSON;
14613
+ exports.geoJson = geoJson;
14614
+ exports.Layer = Layer;
14615
+ exports.LayerGroup = LayerGroup;
14616
+ exports.layerGroup = layerGroup;
14617
+ exports.FeatureGroup = FeatureGroup;
14618
+ exports.featureGroup = featureGroup;
14619
+ exports.ImageOverlay = ImageOverlay;
14620
+ exports.imageOverlay = imageOverlay;
14621
+ exports.VideoOverlay = VideoOverlay;
14622
+ exports.videoOverlay = videoOverlay;
14623
+ exports.SVGOverlay = SVGOverlay;
14624
+ exports.svgOverlay = svgOverlay;
14625
+ exports.DivOverlay = DivOverlay;
14626
+ exports.Popup = Popup;
14627
+ exports.popup = popup;
14628
+ exports.Tooltip = Tooltip;
14629
+ exports.tooltip = tooltip;
14630
+ exports.Icon = Icon;
14631
+ exports.icon = icon;
14632
+ exports.DivIcon = DivIcon;
14633
+ exports.divIcon = divIcon;
14634
+ exports.Marker = Marker;
14635
+ exports.marker = marker;
14636
+ exports.TileLayer = TileLayer;
14637
+ exports.tileLayer = tileLayer;
14638
+ exports.GridLayer = GridLayer;
14639
+ exports.gridLayer = gridLayer;
14640
+ exports.SVG = SVG;
14641
+ exports.svg = svg$1;
14642
+ exports.Renderer = Renderer;
14643
+ exports.Canvas = Canvas;
14644
+ exports.canvas = canvas$1;
14645
+ exports.Path = Path;
14646
+ exports.CircleMarker = CircleMarker;
14647
+ exports.circleMarker = circleMarker;
14648
+ exports.Circle = Circle;
14649
+ exports.circle = circle;
14650
+ exports.Polyline = Polyline;
14651
+ exports.polyline = polyline;
14652
+ exports.Polygon = Polygon;
14653
+ exports.polygon = polygon;
14654
+ exports.Rectangle = Rectangle;
14655
+ exports.rectangle = rectangle;
14656
+ exports.Map = Map;
14657
+ exports.map = createMap;
14207
14658
 
14208
- // @option tapTolerance: Number = 15
14209
- // The max number of pixels a user can shift his finger during touch
14210
- // for it to be considered a valid tap.
14211
- tapTolerance: 15
14212
- });
14659
+ var oldL = window.L;
14660
+ exports.noConflict = function() {
14661
+ window.L = oldL;
14662
+ return this;
14663
+ };
14213
14664
 
14214
- var Tap = Handler.extend({
14215
- addHooks: function () {
14216
- on(this._map._container, 'touchstart', this._onDown, this);
14217
- },
14665
+ // Always export us to window global (see #2364)
14666
+ window.L = exports;
14218
14667
 
14219
- removeHooks: function () {
14220
- off(this._map._container, 'touchstart', this._onDown, this);
14221
- },
14668
+ })));
14669
+
14670
+ } (leafletSrc$1, leafletSrc$1.exports));
14671
+ return leafletSrc$1.exports;
14672
+ }
14222
14673
 
14223
- _onDown: function (e) {
14224
- if (!e.touches) { return; }
14674
+ var leafletSrcExports = /*@__PURE__*/ requireLeafletSrc();
14225
14675
 
14226
- preventDefault(e);
14676
+ var __defProp$f = Object.defineProperty;
14677
+ var __defProps$7 = Object.defineProperties;
14678
+ var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
14679
+ var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
14680
+ var __hasOwnProp$b = Object.prototype.hasOwnProperty;
14681
+ var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
14682
+ var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14683
+ var __spreadValues$b = (a, b) => {
14684
+ for (var prop in b || (b = {}))
14685
+ if (__hasOwnProp$b.call(b, prop))
14686
+ __defNormalProp$f(a, prop, b[prop]);
14687
+ if (__getOwnPropSymbols$b)
14688
+ for (var prop of __getOwnPropSymbols$b(b)) {
14689
+ if (__propIsEnum$b.call(b, prop))
14690
+ __defNormalProp$f(a, prop, b[prop]);
14691
+ }
14692
+ return a;
14693
+ };
14694
+ var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
14695
+ function createControl(control, options = {}, map) {
14696
+ const resolvedOptions = resolveControlOptions(options);
14697
+ const C = leafletSrcExports.Control.extend({
14698
+ onAdd(leafletMap) {
14699
+ const addClass = [
14700
+ "leaflet-control",
14701
+ resolvedOptions.bar ? "leaflet-bar" : "",
14702
+ resolvedOptions.addClass
14703
+ ].filter(Boolean).join(" ");
14704
+ const element = createControlElement(
14705
+ control,
14706
+ __spreadProps$7(__spreadValues$b({}, resolvedOptions), { addClass }),
14707
+ map != null ? map : leafletMap
14708
+ );
14709
+ if (!resolvedOptions.margin) {
14710
+ element.style.margin = "0px";
14711
+ }
14712
+ return element;
14713
+ },
14714
+ onRemove(leafletMap) {
14715
+ control.onRemove(map != null ? map : leafletMap);
14716
+ }
14717
+ });
14718
+ const instance = new C();
14719
+ setControlOptions(instance, resolvedOptions);
14720
+ return instance;
14721
+ }
14227
14722
 
14228
- this._fireClick = true;
14723
+ function createButtonControl(options, map) {
14724
+ return createControl(
14725
+ createButtonControlContent(options),
14726
+ { bar: true, margin: options.margin },
14727
+ map
14728
+ );
14729
+ }
14229
14730
 
14230
- // don't simulate click or track longpress if more than 1 touch
14231
- if (e.touches.length > 1) {
14232
- this._fireClick = false;
14233
- clearTimeout(this._holdTimeout);
14234
- return;
14235
- }
14731
+ function createToggleControl(options, map) {
14732
+ const toggleContent = createToggleControlContent(options);
14733
+ const control = createControl(
14734
+ toggleContent,
14735
+ { bar: true, margin: options.margin },
14736
+ map
14737
+ );
14738
+ control.onClick = toggleContent.onClick;
14739
+ control.changeStatus = toggleContent.changeStatus;
14740
+ control.getStatus = toggleContent.getStatus;
14741
+ control.switch = toggleContent.switch;
14742
+ Object.defineProperty(control, "disableOnSecondClick", {
14743
+ configurable: true,
14744
+ get: () => toggleContent.disableOnSecondClick,
14745
+ set: (value) => {
14746
+ toggleContent.disableOnSecondClick = value;
14747
+ }
14748
+ });
14749
+ control.onStatusChange = toggleContent.onStatusChange;
14750
+ return control;
14751
+ }
14236
14752
 
14237
- var first = e.touches[0],
14238
- el = first.target;
14753
+ var __defProp$e = Object.defineProperty;
14754
+ var __defProps$6 = Object.defineProperties;
14755
+ var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
14756
+ var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
14757
+ var __hasOwnProp$a = Object.prototype.hasOwnProperty;
14758
+ var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
14759
+ var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14760
+ var __spreadValues$a = (a, b) => {
14761
+ for (var prop in b || (b = {}))
14762
+ if (__hasOwnProp$a.call(b, prop))
14763
+ __defNormalProp$e(a, prop, b[prop]);
14764
+ if (__getOwnPropSymbols$a)
14765
+ for (var prop of __getOwnPropSymbols$a(b)) {
14766
+ if (__propIsEnum$a.call(b, prop))
14767
+ __defNormalProp$e(a, prop, b[prop]);
14768
+ }
14769
+ return a;
14770
+ };
14771
+ var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
14772
+ var __publicField$9 = (obj, key, value) => __defNormalProp$e(obj, typeof key !== "symbol" ? key + "" : key, value);
14773
+ class LeafletControlContainer {
14774
+ constructor(map, options = {}) {
14775
+ __publicField$9(this, "map");
14776
+ __publicField$9(this, "controlContainer");
14777
+ __publicField$9(this, "targets", /* @__PURE__ */ new WeakMap());
14778
+ __publicField$9(this, "ids", /* @__PURE__ */ new WeakMap());
14779
+ this.map = map;
14780
+ this.controlContainer = this.createControlContainer(options);
14781
+ this.controlContainer.addTo(map.getContainer());
14782
+ }
14783
+ addControl(control, position, options = {}) {
14784
+ const targetPosition = typeof position === "string" ? position : "top-left";
14785
+ control.options.position = targetPosition.replace(
14786
+ "-",
14787
+ ""
14788
+ );
14789
+ this.map.addControl(control);
14790
+ const container = control.getContainer();
14791
+ if (container) {
14792
+ this.controlContainer.append(container, position, options.order, control);
14793
+ this.targets.set(control, container);
14794
+ if (options.id) {
14795
+ this.controlContainer.registerIDContainer(
14796
+ options.id,
14797
+ container,
14798
+ control
14799
+ );
14800
+ this.ids.set(control, options.id);
14801
+ }
14802
+ }
14803
+ return control;
14804
+ }
14805
+ removeControl(control) {
14806
+ this.map.removeControl(control);
14807
+ const id = this.ids.get(control);
14808
+ if (id) {
14809
+ this.controlContainer.unregisterIDContainer(id);
14810
+ this.ids.delete(control);
14811
+ }
14812
+ const target = this.targets.get(control);
14813
+ if (target) {
14814
+ this.controlContainer.removeTarget(target);
14815
+ this.targets.delete(control);
14816
+ }
14817
+ }
14818
+ append(element, position, order = 0) {
14819
+ this.controlContainer.append(element, position, order);
14820
+ }
14821
+ registerIDContainer(id, controlRoot, control) {
14822
+ this.controlContainer.registerIDContainer(id, controlRoot, control);
14823
+ }
14824
+ unregisterIDContainer(id) {
14825
+ this.controlContainer.unregisterIDContainer(id);
14826
+ }
14827
+ detach() {
14828
+ this.controlContainer.detach();
14829
+ }
14830
+ getContainer() {
14831
+ return this.controlContainer.getContainer();
14832
+ }
14833
+ getControlContainer() {
14834
+ return this.controlContainer;
14835
+ }
14836
+ createControlContainer(options) {
14837
+ const mapAny = this.map;
14838
+ const controlCorners = mapAny._controlCorners || {};
14839
+ const getCorner = (key, selector) => controlCorners[key] || this.map.getContainer().querySelector(selector) || void 0;
14840
+ return new ControlContainer(__spreadProps$6(__spreadValues$a({}, options), {
14841
+ map: this.map,
14842
+ container: mapAny._controlContainer,
14843
+ positionContainers: {
14844
+ "top-left": getCorner("topleft", ".leaflet-top.leaflet-left"),
14845
+ "top-right": getCorner("topright", ".leaflet-top.leaflet-right"),
14846
+ "bottom-left": getCorner("bottomleft", ".leaflet-bottom.leaflet-left"),
14847
+ "bottom-right": getCorner(
14848
+ "bottomright",
14849
+ ".leaflet-bottom.leaflet-right"
14850
+ )
14851
+ }
14852
+ }));
14853
+ }
14854
+ }
14239
14855
 
14240
- this._startPos = this._newPos = new Point(first.clientX, first.clientY);
14856
+ var domain;
14241
14857
 
14242
- // if touching a link, highlight it
14243
- if (el.tagName && el.tagName.toLowerCase() === 'a') {
14244
- addClass(el, 'leaflet-active');
14245
- }
14858
+ // This constructor is used to store event handlers. Instantiating this is
14859
+ // faster than explicitly calling `Object.create(null)` to get a "clean" empty
14860
+ // object (tested with v8 v4.9).
14861
+ function EventHandlers() {}
14862
+ EventHandlers.prototype = Object.create(null);
14246
14863
 
14247
- // simulate long hold but setting a timeout
14248
- this._holdTimeout = setTimeout(bind(function () {
14249
- if (this._isTapValid()) {
14250
- this._fireClick = false;
14251
- this._onUp();
14252
- this._simulateEvent('contextmenu', first);
14253
- }
14254
- }, this), 1000);
14864
+ function EventEmitter() {
14865
+ EventEmitter.init.call(this);
14866
+ }
14255
14867
 
14256
- this._simulateEvent('mousedown', first);
14868
+ // nodejs oddity
14869
+ // require('events') === require('events').EventEmitter
14870
+ EventEmitter.EventEmitter = EventEmitter;
14257
14871
 
14258
- on(document, {
14259
- touchmove: this._onMove,
14260
- touchend: this._onUp
14261
- }, this);
14262
- },
14872
+ EventEmitter.usingDomains = false;
14263
14873
 
14264
- _onUp: function (e) {
14265
- clearTimeout(this._holdTimeout);
14874
+ EventEmitter.prototype.domain = undefined;
14875
+ EventEmitter.prototype._events = undefined;
14876
+ EventEmitter.prototype._maxListeners = undefined;
14266
14877
 
14267
- off(document, {
14268
- touchmove: this._onMove,
14269
- touchend: this._onUp
14270
- }, this);
14878
+ // By default EventEmitters will print a warning if more than 10 listeners are
14879
+ // added to it. This is a useful default which helps finding memory leaks.
14880
+ EventEmitter.defaultMaxListeners = 10;
14271
14881
 
14272
- if (this._fireClick && e && e.changedTouches) {
14882
+ EventEmitter.init = function() {
14883
+ this.domain = null;
14884
+ if (EventEmitter.usingDomains) {
14885
+ // if there is an active domain, then attach to it.
14886
+ if (domain.active && !(this instanceof domain.Domain)) {
14887
+ this.domain = domain.active;
14888
+ }
14889
+ }
14273
14890
 
14274
- var first = e.changedTouches[0],
14275
- el = first.target;
14891
+ if (!this._events || this._events === Object.getPrototypeOf(this)._events) {
14892
+ this._events = new EventHandlers();
14893
+ this._eventsCount = 0;
14894
+ }
14276
14895
 
14277
- if (el && el.tagName && el.tagName.toLowerCase() === 'a') {
14278
- removeClass(el, 'leaflet-active');
14279
- }
14896
+ this._maxListeners = this._maxListeners || undefined;
14897
+ };
14898
+
14899
+ // Obviously not all Emitters should be limited to 10. This function allows
14900
+ // that to be increased. Set to zero for unlimited.
14901
+ EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
14902
+ if (typeof n !== 'number' || n < 0 || isNaN(n))
14903
+ throw new TypeError('"n" argument must be a positive number');
14904
+ this._maxListeners = n;
14905
+ return this;
14906
+ };
14280
14907
 
14281
- this._simulateEvent('mouseup', first);
14908
+ function $getMaxListeners(that) {
14909
+ if (that._maxListeners === undefined)
14910
+ return EventEmitter.defaultMaxListeners;
14911
+ return that._maxListeners;
14912
+ }
14282
14913
 
14283
- // simulate click if the touch didn't move too much
14284
- if (this._isTapValid()) {
14285
- this._simulateEvent('click', first);
14286
- }
14287
- }
14288
- },
14914
+ EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
14915
+ return $getMaxListeners(this);
14916
+ };
14289
14917
 
14290
- _isTapValid: function () {
14291
- return this._newPos.distanceTo(this._startPos) <= this._map.options.tapTolerance;
14292
- },
14918
+ // These standalone emit* functions are used to optimize calling of event
14919
+ // handlers for fast cases because emit() itself often has a variable number of
14920
+ // arguments and can be deoptimized because of that. These functions always have
14921
+ // the same number of arguments and thus do not get deoptimized, so the code
14922
+ // inside them can execute faster.
14923
+ function emitNone(handler, isFn, self) {
14924
+ if (isFn)
14925
+ handler.call(self);
14926
+ else {
14927
+ var len = handler.length;
14928
+ var listeners = arrayClone(handler, len);
14929
+ for (var i = 0; i < len; ++i)
14930
+ listeners[i].call(self);
14931
+ }
14932
+ }
14933
+ function emitOne(handler, isFn, self, arg1) {
14934
+ if (isFn)
14935
+ handler.call(self, arg1);
14936
+ else {
14937
+ var len = handler.length;
14938
+ var listeners = arrayClone(handler, len);
14939
+ for (var i = 0; i < len; ++i)
14940
+ listeners[i].call(self, arg1);
14941
+ }
14942
+ }
14943
+ function emitTwo(handler, isFn, self, arg1, arg2) {
14944
+ if (isFn)
14945
+ handler.call(self, arg1, arg2);
14946
+ else {
14947
+ var len = handler.length;
14948
+ var listeners = arrayClone(handler, len);
14949
+ for (var i = 0; i < len; ++i)
14950
+ listeners[i].call(self, arg1, arg2);
14951
+ }
14952
+ }
14953
+ function emitThree(handler, isFn, self, arg1, arg2, arg3) {
14954
+ if (isFn)
14955
+ handler.call(self, arg1, arg2, arg3);
14956
+ else {
14957
+ var len = handler.length;
14958
+ var listeners = arrayClone(handler, len);
14959
+ for (var i = 0; i < len; ++i)
14960
+ listeners[i].call(self, arg1, arg2, arg3);
14961
+ }
14962
+ }
14293
14963
 
14294
- _onMove: function (e) {
14295
- var first = e.touches[0];
14296
- this._newPos = new Point(first.clientX, first.clientY);
14297
- this._simulateEvent('mousemove', first);
14298
- },
14964
+ function emitMany(handler, isFn, self, args) {
14965
+ if (isFn)
14966
+ handler.apply(self, args);
14967
+ else {
14968
+ var len = handler.length;
14969
+ var listeners = arrayClone(handler, len);
14970
+ for (var i = 0; i < len; ++i)
14971
+ listeners[i].apply(self, args);
14972
+ }
14973
+ }
14299
14974
 
14300
- _simulateEvent: function (type, e) {
14301
- var simulatedEvent = document.createEvent('MouseEvents');
14975
+ EventEmitter.prototype.emit = function emit(type) {
14976
+ var er, handler, len, args, i, events, domain;
14977
+ var doError = (type === 'error');
14302
14978
 
14303
- simulatedEvent._simulated = true;
14304
- e.target._simulatedClick = true;
14979
+ events = this._events;
14980
+ if (events)
14981
+ doError = (doError && events.error == null);
14982
+ else if (!doError)
14983
+ return false;
14305
14984
 
14306
- simulatedEvent.initMouseEvent(
14307
- type, true, true, window, 1,
14308
- e.screenX, e.screenY,
14309
- e.clientX, e.clientY,
14310
- false, false, false, false, 0, null);
14985
+ domain = this.domain;
14311
14986
 
14312
- e.target.dispatchEvent(simulatedEvent);
14313
- }
14314
- });
14987
+ // If there is no 'error' event listener then throw.
14988
+ if (doError) {
14989
+ er = arguments[1];
14990
+ if (domain) {
14991
+ if (!er)
14992
+ er = new Error('Uncaught, unspecified "error" event');
14993
+ er.domainEmitter = this;
14994
+ er.domain = domain;
14995
+ er.domainThrown = false;
14996
+ domain.emit('error', er);
14997
+ } else if (er instanceof Error) {
14998
+ throw er; // Unhandled 'error' event
14999
+ } else {
15000
+ // At least give some kind of context to the user
15001
+ var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
15002
+ err.context = er;
15003
+ throw err;
15004
+ }
15005
+ return false;
15006
+ }
14315
15007
 
14316
- // @section Handlers
14317
- // @property tap: Handler
14318
- // Mobile touch hacks (quick tap and touch hold) handler.
14319
- if (touch && (!pointer || safari)) {
14320
- Map.addInitHook('addHandler', 'tap', Tap);
14321
- }
15008
+ handler = events[type];
14322
15009
 
14323
- /*
14324
- * L.Handler.TouchZoom is used by L.Map to add pinch zoom on supported mobile browsers.
14325
- */
15010
+ if (!handler)
15011
+ return false;
14326
15012
 
14327
- // @namespace Map
14328
- // @section Interaction Options
14329
- Map.mergeOptions({
14330
- // @section Touch interaction options
14331
- // @option touchZoom: Boolean|String = *
14332
- // Whether the map can be zoomed by touch-dragging with two fingers. If
14333
- // passed `'center'`, it will zoom to the center of the view regardless of
14334
- // where the touch events (fingers) were. Enabled for touch-capable web
14335
- // browsers except for old Androids.
14336
- touchZoom: touch && !android23,
15013
+ var isFn = typeof handler === 'function';
15014
+ len = arguments.length;
15015
+ switch (len) {
15016
+ // fast cases
15017
+ case 1:
15018
+ emitNone(handler, isFn, this);
15019
+ break;
15020
+ case 2:
15021
+ emitOne(handler, isFn, this, arguments[1]);
15022
+ break;
15023
+ case 3:
15024
+ emitTwo(handler, isFn, this, arguments[1], arguments[2]);
15025
+ break;
15026
+ case 4:
15027
+ emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
15028
+ break;
15029
+ // slower
15030
+ default:
15031
+ args = new Array(len - 1);
15032
+ for (i = 1; i < len; i++)
15033
+ args[i - 1] = arguments[i];
15034
+ emitMany(handler, isFn, this, args);
15035
+ }
14337
15036
 
14338
- // @option bounceAtZoomLimits: Boolean = true
14339
- // Set it to false if you don't want the map to zoom beyond min/max zoom
14340
- // and then bounce back when pinch-zooming.
14341
- bounceAtZoomLimits: true
14342
- });
15037
+ return true;
15038
+ };
14343
15039
 
14344
- var TouchZoom = Handler.extend({
14345
- addHooks: function () {
14346
- addClass(this._map._container, 'leaflet-touch-zoom');
14347
- on(this._map._container, 'touchstart', this._onTouchStart, this);
14348
- },
15040
+ function _addListener(target, type, listener, prepend) {
15041
+ var m;
15042
+ var events;
15043
+ var existing;
14349
15044
 
14350
- removeHooks: function () {
14351
- removeClass(this._map._container, 'leaflet-touch-zoom');
14352
- off(this._map._container, 'touchstart', this._onTouchStart, this);
14353
- },
15045
+ if (typeof listener !== 'function')
15046
+ throw new TypeError('"listener" argument must be a function');
14354
15047
 
14355
- _onTouchStart: function (e) {
14356
- var map = this._map;
14357
- if (!e.touches || e.touches.length !== 2 || map._animatingZoom || this._zooming) { return; }
15048
+ events = target._events;
15049
+ if (!events) {
15050
+ events = target._events = new EventHandlers();
15051
+ target._eventsCount = 0;
15052
+ } else {
15053
+ // To avoid recursion in the case that type === "newListener"! Before
15054
+ // adding it to the listeners, first emit "newListener".
15055
+ if (events.newListener) {
15056
+ target.emit('newListener', type,
15057
+ listener.listener ? listener.listener : listener);
14358
15058
 
14359
- var p1 = map.mouseEventToContainerPoint(e.touches[0]),
14360
- p2 = map.mouseEventToContainerPoint(e.touches[1]);
15059
+ // Re-assign `events` because a newListener handler could have caused the
15060
+ // this._events to be assigned to a new object
15061
+ events = target._events;
15062
+ }
15063
+ existing = events[type];
15064
+ }
14361
15065
 
14362
- this._centerPoint = map.getSize()._divideBy(2);
14363
- this._startLatLng = map.containerPointToLatLng(this._centerPoint);
14364
- if (map.options.touchZoom !== 'center') {
14365
- this._pinchStartLatLng = map.containerPointToLatLng(p1.add(p2)._divideBy(2));
14366
- }
15066
+ if (!existing) {
15067
+ // Optimize the case of one listener. Don't need the extra array object.
15068
+ existing = events[type] = listener;
15069
+ ++target._eventsCount;
15070
+ } else {
15071
+ if (typeof existing === 'function') {
15072
+ // Adding the second element, need to change to array.
15073
+ existing = events[type] = prepend ? [listener, existing] :
15074
+ [existing, listener];
15075
+ } else {
15076
+ // If we've already got an array, just append.
15077
+ if (prepend) {
15078
+ existing.unshift(listener);
15079
+ } else {
15080
+ existing.push(listener);
15081
+ }
15082
+ }
14367
15083
 
14368
- this._startDist = p1.distanceTo(p2);
14369
- this._startZoom = map.getZoom();
15084
+ // Check for listener leak
15085
+ if (!existing.warned) {
15086
+ m = $getMaxListeners(target);
15087
+ if (m && m > 0 && existing.length > m) {
15088
+ existing.warned = true;
15089
+ var w = new Error('Possible EventEmitter memory leak detected. ' +
15090
+ existing.length + ' ' + type + ' listeners added. ' +
15091
+ 'Use emitter.setMaxListeners() to increase limit');
15092
+ w.name = 'MaxListenersExceededWarning';
15093
+ w.emitter = target;
15094
+ w.type = type;
15095
+ w.count = existing.length;
15096
+ emitWarning(w);
15097
+ }
15098
+ }
15099
+ }
14370
15100
 
14371
- this._moved = false;
14372
- this._zooming = true;
15101
+ return target;
15102
+ }
15103
+ function emitWarning(e) {
15104
+ typeof console.warn === 'function' ? console.warn(e) : console.log(e);
15105
+ }
15106
+ EventEmitter.prototype.addListener = function addListener(type, listener) {
15107
+ return _addListener(this, type, listener, false);
15108
+ };
14373
15109
 
14374
- map._stop();
15110
+ EventEmitter.prototype.on = EventEmitter.prototype.addListener;
14375
15111
 
14376
- on(document, 'touchmove', this._onTouchMove, this);
14377
- on(document, 'touchend', this._onTouchEnd, this);
15112
+ EventEmitter.prototype.prependListener =
15113
+ function prependListener(type, listener) {
15114
+ return _addListener(this, type, listener, true);
15115
+ };
14378
15116
 
14379
- preventDefault(e);
14380
- },
15117
+ function _onceWrap(target, type, listener) {
15118
+ var fired = false;
15119
+ function g() {
15120
+ target.removeListener(type, g);
15121
+ if (!fired) {
15122
+ fired = true;
15123
+ listener.apply(target, arguments);
15124
+ }
15125
+ }
15126
+ g.listener = listener;
15127
+ return g;
15128
+ }
14381
15129
 
14382
- _onTouchMove: function (e) {
14383
- if (!e.touches || e.touches.length !== 2 || !this._zooming) { return; }
15130
+ EventEmitter.prototype.once = function once(type, listener) {
15131
+ if (typeof listener !== 'function')
15132
+ throw new TypeError('"listener" argument must be a function');
15133
+ this.on(type, _onceWrap(this, type, listener));
15134
+ return this;
15135
+ };
14384
15136
 
14385
- var map = this._map,
14386
- p1 = map.mouseEventToContainerPoint(e.touches[0]),
14387
- p2 = map.mouseEventToContainerPoint(e.touches[1]),
14388
- scale = p1.distanceTo(p2) / this._startDist;
15137
+ EventEmitter.prototype.prependOnceListener =
15138
+ function prependOnceListener(type, listener) {
15139
+ if (typeof listener !== 'function')
15140
+ throw new TypeError('"listener" argument must be a function');
15141
+ this.prependListener(type, _onceWrap(this, type, listener));
15142
+ return this;
15143
+ };
14389
15144
 
14390
- this._zoom = map.getScaleZoom(scale, this._startZoom);
15145
+ // emits a 'removeListener' event iff the listener was removed
15146
+ EventEmitter.prototype.removeListener =
15147
+ function removeListener(type, listener) {
15148
+ var list, events, position, i, originalListener;
14391
15149
 
14392
- if (!map.options.bounceAtZoomLimits && (
14393
- (this._zoom < map.getMinZoom() && scale < 1) ||
14394
- (this._zoom > map.getMaxZoom() && scale > 1))) {
14395
- this._zoom = map._limitZoom(this._zoom);
14396
- }
15150
+ if (typeof listener !== 'function')
15151
+ throw new TypeError('"listener" argument must be a function');
14397
15152
 
14398
- if (map.options.touchZoom === 'center') {
14399
- this._center = this._startLatLng;
14400
- if (scale === 1) { return; }
14401
- } else {
14402
- // Get delta from pinch to center, so centerLatLng is delta applied to initial pinchLatLng
14403
- var delta = p1._add(p2)._divideBy(2)._subtract(this._centerPoint);
14404
- if (scale === 1 && delta.x === 0 && delta.y === 0) { return; }
14405
- this._center = map.unproject(map.project(this._pinchStartLatLng, this._zoom).subtract(delta), this._zoom);
14406
- }
15153
+ events = this._events;
15154
+ if (!events)
15155
+ return this;
14407
15156
 
14408
- if (!this._moved) {
14409
- map._moveStart(true, false);
14410
- this._moved = true;
14411
- }
15157
+ list = events[type];
15158
+ if (!list)
15159
+ return this;
14412
15160
 
14413
- cancelAnimFrame(this._animRequest);
15161
+ if (list === listener || (list.listener && list.listener === listener)) {
15162
+ if (--this._eventsCount === 0)
15163
+ this._events = new EventHandlers();
15164
+ else {
15165
+ delete events[type];
15166
+ if (events.removeListener)
15167
+ this.emit('removeListener', type, list.listener || listener);
15168
+ }
15169
+ } else if (typeof list !== 'function') {
15170
+ position = -1;
14414
15171
 
14415
- var moveFn = bind(map._move, map, this._center, this._zoom, {pinch: true, round: false});
14416
- this._animRequest = requestAnimFrame(moveFn, this, true);
15172
+ for (i = list.length; i-- > 0;) {
15173
+ if (list[i] === listener ||
15174
+ (list[i].listener && list[i].listener === listener)) {
15175
+ originalListener = list[i].listener;
15176
+ position = i;
15177
+ break;
15178
+ }
15179
+ }
14417
15180
 
14418
- preventDefault(e);
14419
- },
15181
+ if (position < 0)
15182
+ return this;
14420
15183
 
14421
- _onTouchEnd: function () {
14422
- if (!this._moved || !this._zooming) {
14423
- this._zooming = false;
14424
- return;
14425
- }
15184
+ if (list.length === 1) {
15185
+ list[0] = undefined;
15186
+ if (--this._eventsCount === 0) {
15187
+ this._events = new EventHandlers();
15188
+ return this;
15189
+ } else {
15190
+ delete events[type];
15191
+ }
15192
+ } else {
15193
+ spliceOne(list, position);
15194
+ }
14426
15195
 
14427
- this._zooming = false;
14428
- cancelAnimFrame(this._animRequest);
15196
+ if (events.removeListener)
15197
+ this.emit('removeListener', type, originalListener || listener);
15198
+ }
14429
15199
 
14430
- off(document, 'touchmove', this._onTouchMove, this);
14431
- off(document, 'touchend', this._onTouchEnd, this);
15200
+ return this;
15201
+ };
15202
+
15203
+ // Alias for removeListener added in NodeJS 10.0
15204
+ // https://nodejs.org/api/events.html#events_emitter_off_eventname_listener
15205
+ EventEmitter.prototype.off = function(type, listener){
15206
+ return this.removeListener(type, listener);
15207
+ };
14432
15208
 
14433
- // Pinch updates GridLayers' levels only when zoomSnap is off, so zoomSnap becomes noUpdate.
14434
- if (this._map.options.zoomAnimation) {
14435
- this._map._animateZoom(this._center, this._map._limitZoom(this._zoom), true, this._map.options.zoomSnap);
14436
- } else {
14437
- this._map._resetView(this._center, this._map._limitZoom(this._zoom));
14438
- }
14439
- }
14440
- });
15209
+ EventEmitter.prototype.removeAllListeners =
15210
+ function removeAllListeners(type) {
15211
+ var listeners, events;
14441
15212
 
14442
- // @section Handlers
14443
- // @property touchZoom: Handler
14444
- // Touch zoom handler.
14445
- Map.addInitHook('addHandler', 'touchZoom', TouchZoom);
15213
+ events = this._events;
15214
+ if (!events)
15215
+ return this;
14446
15216
 
14447
- Map.BoxZoom = BoxZoom;
14448
- Map.DoubleClickZoom = DoubleClickZoom;
14449
- Map.Drag = Drag;
14450
- Map.Keyboard = Keyboard;
14451
- Map.ScrollWheelZoom = ScrollWheelZoom;
14452
- Map.Tap = Tap;
14453
- Map.TouchZoom = TouchZoom;
15217
+ // not listening for removeListener, no need to emit
15218
+ if (!events.removeListener) {
15219
+ if (arguments.length === 0) {
15220
+ this._events = new EventHandlers();
15221
+ this._eventsCount = 0;
15222
+ } else if (events[type]) {
15223
+ if (--this._eventsCount === 0)
15224
+ this._events = new EventHandlers();
15225
+ else
15226
+ delete events[type];
15227
+ }
15228
+ return this;
15229
+ }
14454
15230
 
14455
- exports.version = version;
14456
- exports.Control = Control;
14457
- exports.control = control;
14458
- exports.Browser = Browser;
14459
- exports.Evented = Evented;
14460
- exports.Mixin = Mixin;
14461
- exports.Util = Util;
14462
- exports.Class = Class;
14463
- exports.Handler = Handler;
14464
- exports.extend = extend;
14465
- exports.bind = bind;
14466
- exports.stamp = stamp;
14467
- exports.setOptions = setOptions;
14468
- exports.DomEvent = DomEvent;
14469
- exports.DomUtil = DomUtil;
14470
- exports.PosAnimation = PosAnimation;
14471
- exports.Draggable = Draggable;
14472
- exports.LineUtil = LineUtil;
14473
- exports.PolyUtil = PolyUtil;
14474
- exports.Point = Point;
14475
- exports.point = toPoint;
14476
- exports.Bounds = Bounds;
14477
- exports.bounds = toBounds;
14478
- exports.Transformation = Transformation;
14479
- exports.transformation = toTransformation;
14480
- exports.Projection = index;
14481
- exports.LatLng = LatLng;
14482
- exports.latLng = toLatLng;
14483
- exports.LatLngBounds = LatLngBounds;
14484
- exports.latLngBounds = toLatLngBounds;
14485
- exports.CRS = CRS;
14486
- exports.GeoJSON = GeoJSON;
14487
- exports.geoJSON = geoJSON;
14488
- exports.geoJson = geoJson;
14489
- exports.Layer = Layer;
14490
- exports.LayerGroup = LayerGroup;
14491
- exports.layerGroup = layerGroup;
14492
- exports.FeatureGroup = FeatureGroup;
14493
- exports.featureGroup = featureGroup;
14494
- exports.ImageOverlay = ImageOverlay;
14495
- exports.imageOverlay = imageOverlay;
14496
- exports.VideoOverlay = VideoOverlay;
14497
- exports.videoOverlay = videoOverlay;
14498
- exports.SVGOverlay = SVGOverlay;
14499
- exports.svgOverlay = svgOverlay;
14500
- exports.DivOverlay = DivOverlay;
14501
- exports.Popup = Popup;
14502
- exports.popup = popup;
14503
- exports.Tooltip = Tooltip;
14504
- exports.tooltip = tooltip;
14505
- exports.Icon = Icon;
14506
- exports.icon = icon;
14507
- exports.DivIcon = DivIcon;
14508
- exports.divIcon = divIcon;
14509
- exports.Marker = Marker;
14510
- exports.marker = marker;
14511
- exports.TileLayer = TileLayer;
14512
- exports.tileLayer = tileLayer;
14513
- exports.GridLayer = GridLayer;
14514
- exports.gridLayer = gridLayer;
14515
- exports.SVG = SVG;
14516
- exports.svg = svg$1;
14517
- exports.Renderer = Renderer;
14518
- exports.Canvas = Canvas;
14519
- exports.canvas = canvas$1;
14520
- exports.Path = Path;
14521
- exports.CircleMarker = CircleMarker;
14522
- exports.circleMarker = circleMarker;
14523
- exports.Circle = Circle;
14524
- exports.circle = circle;
14525
- exports.Polyline = Polyline;
14526
- exports.polyline = polyline;
14527
- exports.Polygon = Polygon;
14528
- exports.polygon = polygon;
14529
- exports.Rectangle = Rectangle;
14530
- exports.rectangle = rectangle;
14531
- exports.Map = Map;
14532
- exports.map = createMap;
15231
+ // emit removeListener for all listeners on all events
15232
+ if (arguments.length === 0) {
15233
+ var keys = Object.keys(events);
15234
+ for (var i = 0, key; i < keys.length; ++i) {
15235
+ key = keys[i];
15236
+ if (key === 'removeListener') continue;
15237
+ this.removeAllListeners(key);
15238
+ }
15239
+ this.removeAllListeners('removeListener');
15240
+ this._events = new EventHandlers();
15241
+ this._eventsCount = 0;
15242
+ return this;
15243
+ }
14533
15244
 
14534
- var oldL = window.L;
14535
- exports.noConflict = function() {
14536
- window.L = oldL;
14537
- return this;
14538
- };
15245
+ listeners = events[type];
14539
15246
 
14540
- // Always export us to window global (see #2364)
14541
- window.L = exports;
15247
+ if (typeof listeners === 'function') {
15248
+ this.removeListener(type, listeners);
15249
+ } else if (listeners) {
15250
+ // LIFO order
15251
+ do {
15252
+ this.removeListener(type, listeners[listeners.length - 1]);
15253
+ } while (listeners[0]);
15254
+ }
14542
15255
 
14543
- })));
14544
-
14545
- } (leafletSrc$1, leafletSrc$1.exports));
14546
- return leafletSrc$1.exports;
15256
+ return this;
15257
+ };
15258
+
15259
+ EventEmitter.prototype.listeners = function listeners(type) {
15260
+ var evlistener;
15261
+ var ret;
15262
+ var events = this._events;
15263
+
15264
+ if (!events)
15265
+ ret = [];
15266
+ else {
15267
+ evlistener = events[type];
15268
+ if (!evlistener)
15269
+ ret = [];
15270
+ else if (typeof evlistener === 'function')
15271
+ ret = [evlistener.listener || evlistener];
15272
+ else
15273
+ ret = unwrapListeners(evlistener);
15274
+ }
15275
+
15276
+ return ret;
15277
+ };
15278
+
15279
+ EventEmitter.listenerCount = function(emitter, type) {
15280
+ if (typeof emitter.listenerCount === 'function') {
15281
+ return emitter.listenerCount(type);
15282
+ } else {
15283
+ return listenerCount.call(emitter, type);
15284
+ }
15285
+ };
15286
+
15287
+ EventEmitter.prototype.listenerCount = listenerCount;
15288
+ function listenerCount(type) {
15289
+ var events = this._events;
15290
+
15291
+ if (events) {
15292
+ var evlistener = events[type];
15293
+
15294
+ if (typeof evlistener === 'function') {
15295
+ return 1;
15296
+ } else if (evlistener) {
15297
+ return evlistener.length;
15298
+ }
15299
+ }
15300
+
15301
+ return 0;
14547
15302
  }
14548
15303
 
14549
- var leafletSrcExports = /*@__PURE__*/ requireLeafletSrc();
15304
+ EventEmitter.prototype.eventNames = function eventNames() {
15305
+ return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
15306
+ };
15307
+
15308
+ // About 1.5x faster than the two-arg version of Array#splice().
15309
+ function spliceOne(list, index) {
15310
+ for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
15311
+ list[i] = list[k];
15312
+ list.pop();
15313
+ }
15314
+
15315
+ function arrayClone(arr, i) {
15316
+ var copy = new Array(i);
15317
+ while (i--)
15318
+ copy[i] = arr[i];
15319
+ return copy;
15320
+ }
15321
+
15322
+ function unwrapListeners(arr) {
15323
+ var ret = new Array(arr.length);
15324
+ for (var i = 0; i < ret.length; ++i) {
15325
+ ret[i] = arr[i].listener || arr[i];
15326
+ }
15327
+ return ret;
15328
+ }
14550
15329
 
14551
15330
  class AttributionControl extends leafletSrcExports.Control.Attribution {
14552
15331
  // options: AttributionControlOptions
@@ -14565,81 +15344,6 @@ var LeafletMapAdapter = (function () {
14565
15344
  }
14566
15345
  }
14567
15346
 
14568
- function createControl(control, options = {}, map) {
14569
- const C = leafletSrcExports.Control.extend({
14570
- onAdd() {
14571
- const element = document.createElement("div");
14572
- const content = control.onAdd(map);
14573
- element.classList.add("leaflet-control");
14574
- if (options.bar) {
14575
- element.classList.add("leaflet-bar");
14576
- }
14577
- if (options.addClass) {
14578
- element.classList.add(options.addClass);
14579
- }
14580
- if (!options.margin && !options.bar) {
14581
- element.style.marginBottom = "0px";
14582
- element.style.marginTop = "0px";
14583
- element.style.marginLeft = "0px";
14584
- element.style.marginRight = "0px";
14585
- }
14586
- if (content) {
14587
- element.appendChild(content);
14588
- }
14589
- leafletSrcExports.DomEvent.disableClickPropagation(element);
14590
- return element;
14591
- },
14592
- onRemove() {
14593
- control.onRemove();
14594
- }
14595
- });
14596
- return new C();
14597
- }
14598
-
14599
- function createButtonControl(options, map) {
14600
- const link = document.createElement("a");
14601
- const title = options.title || "";
14602
- link.href = "#";
14603
- link.title = title;
14604
- link.setAttribute("role", "button");
14605
- link.setAttribute("aria-label", title);
14606
- if (options.addClass) {
14607
- link.classList.add(options.addClass);
14608
- }
14609
- leafletSrcExports.DomEvent.disableClickPropagation(link);
14610
- leafletSrcExports.DomEvent.on(link, "click", leafletSrcExports.DomEvent.stop);
14611
- if (options.html instanceof HTMLElement) {
14612
- link.appendChild(options.html);
14613
- } else if (typeof options.html === "string") {
14614
- link.innerHTML = options.html;
14615
- }
14616
- const onClick = (e) => {
14617
- e.stopPropagation();
14618
- options.onClick();
14619
- };
14620
- return createControl(
14621
- {
14622
- onAdd() {
14623
- if (options.onClick !== void 0) {
14624
- link.addEventListener("click", onClick);
14625
- }
14626
- return link;
14627
- },
14628
- onRemove() {
14629
- const parent = link.parentNode;
14630
- if (parent) {
14631
- parent.removeChild(link);
14632
- }
14633
- if (options.onClick !== void 0) {
14634
- link.removeEventListener("click", onClick);
14635
- }
14636
- }
14637
- },
14638
- { bar: true },
14639
- map
14640
- );
14641
- }
14642
-
14643
15347
  function debounce(cb, wait = 10) {
14644
15348
  let timeoutId;
14645
15349
  function wrapper(...args) {
@@ -14784,9 +15488,9 @@ var LeafletMapAdapter = (function () {
14784
15488
  };
14785
15489
  }
14786
15490
 
14787
- var __defProp$c = Object.defineProperty;
14788
- var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14789
- var __publicField$8 = (obj, key, value) => __defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
15491
+ var __defProp$d = Object.defineProperty;
15492
+ var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15493
+ var __publicField$8 = (obj, key, value) => __defNormalProp$d(obj, typeof key !== "symbol" ? key + "" : key, value);
14790
15494
  class BaseAdapter {
14791
15495
  constructor(map, options) {
14792
15496
  this.map = map;
@@ -14821,19 +15525,19 @@ var LeafletMapAdapter = (function () {
14821
15525
  };
14822
15526
  }
14823
15527
 
14824
- var __defProp$b = Object.defineProperty;
14825
- var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
14826
- var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
14827
- var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
14828
- var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14829
- var __spreadValues$8 = (a, b) => {
15528
+ var __defProp$c = Object.defineProperty;
15529
+ var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
15530
+ var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
15531
+ var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
15532
+ var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15533
+ var __spreadValues$9 = (a, b) => {
14830
15534
  for (var prop in b || (b = {}))
14831
- if (__hasOwnProp$8.call(b, prop))
14832
- __defNormalProp$b(a, prop, b[prop]);
14833
- if (__getOwnPropSymbols$8)
14834
- for (var prop of __getOwnPropSymbols$8(b)) {
14835
- if (__propIsEnum$8.call(b, prop))
14836
- __defNormalProp$b(a, prop, b[prop]);
15535
+ if (__hasOwnProp$9.call(b, prop))
15536
+ __defNormalProp$c(a, prop, b[prop]);
15537
+ if (__getOwnPropSymbols$9)
15538
+ for (var prop of __getOwnPropSymbols$9(b)) {
15539
+ if (__propIsEnum$9.call(b, prop))
15540
+ __defNormalProp$c(a, prop, b[prop]);
14837
15541
  }
14838
15542
  return a;
14839
15543
  };
@@ -14843,7 +15547,7 @@ var LeafletMapAdapter = (function () {
14843
15547
  }) {
14844
15548
  const layer_ = source.target;
14845
15549
  const feature = layer_.feature;
14846
- const opt = __spreadValues$8({
15550
+ const opt = __spreadValues$9({
14847
15551
  layer,
14848
15552
  feature,
14849
15553
  event: convertMapClickEvent(source),
@@ -14852,23 +15556,23 @@ var LeafletMapAdapter = (function () {
14852
15556
  return opt;
14853
15557
  }
14854
15558
 
14855
- var __defProp$a = Object.defineProperty;
14856
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
14857
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
14858
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
14859
- var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14860
- var __spreadValues$7 = (a, b) => {
15559
+ var __defProp$b = Object.defineProperty;
15560
+ var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
15561
+ var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
15562
+ var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
15563
+ var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15564
+ var __spreadValues$8 = (a, b) => {
14861
15565
  for (var prop in b || (b = {}))
14862
- if (__hasOwnProp$7.call(b, prop))
14863
- __defNormalProp$a(a, prop, b[prop]);
14864
- if (__getOwnPropSymbols$7)
14865
- for (var prop of __getOwnPropSymbols$7(b)) {
14866
- if (__propIsEnum$7.call(b, prop))
14867
- __defNormalProp$a(a, prop, b[prop]);
15566
+ if (__hasOwnProp$8.call(b, prop))
15567
+ __defNormalProp$b(a, prop, b[prop]);
15568
+ if (__getOwnPropSymbols$8)
15569
+ for (var prop of __getOwnPropSymbols$8(b)) {
15570
+ if (__propIsEnum$8.call(b, prop))
15571
+ __defNormalProp$b(a, prop, b[prop]);
14868
15572
  }
14869
15573
  return a;
14870
15574
  };
14871
- var __publicField$7 = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
15575
+ var __publicField$7 = (obj, key, value) => __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
14872
15576
  class GeoJsonEvents {
14873
15577
  constructor(layer) {
14874
15578
  __publicField$7(this, "layer");
@@ -14884,7 +15588,7 @@ var LeafletMapAdapter = (function () {
14884
15588
  if (onClick_) {
14885
15589
  this._onclick = (e) => {
14886
15590
  const selected = !!this.layer._getSelected(layer);
14887
- onClick_(__spreadValues$7({
15591
+ onClick_(__spreadValues$8({
14888
15592
  selected
14889
15593
  }, this._createMouseEvent(e)));
14890
15594
  };
@@ -14894,7 +15598,7 @@ var LeafletMapAdapter = (function () {
14894
15598
  this._ondblclick = (e) => {
14895
15599
  leafletSrcExports.DomEvent.stopPropagation(e);
14896
15600
  const selected = !!this.layer._getSelected(layer);
14897
- onDoubleClick(__spreadValues$7({
15601
+ onDoubleClick(__spreadValues$8({
14898
15602
  selected
14899
15603
  }, this._createMouseEvent(e)));
14900
15604
  };
@@ -14945,21 +15649,21 @@ var LeafletMapAdapter = (function () {
14945
15649
  return false;
14946
15650
  }
14947
15651
 
14948
- var __defProp$9 = Object.defineProperty;
15652
+ var __defProp$a = Object.defineProperty;
14949
15653
  var __defProps$5 = Object.defineProperties;
14950
15654
  var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
14951
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
14952
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
14953
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
14954
- var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14955
- var __spreadValues$6 = (a, b) => {
15655
+ var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
15656
+ var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
15657
+ var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
15658
+ var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15659
+ var __spreadValues$7 = (a, b) => {
14956
15660
  for (var prop in b || (b = {}))
14957
- if (__hasOwnProp$6.call(b, prop))
14958
- __defNormalProp$9(a, prop, b[prop]);
14959
- if (__getOwnPropSymbols$6)
14960
- for (var prop of __getOwnPropSymbols$6(b)) {
14961
- if (__propIsEnum$6.call(b, prop))
14962
- __defNormalProp$9(a, prop, b[prop]);
15661
+ if (__hasOwnProp$7.call(b, prop))
15662
+ __defNormalProp$a(a, prop, b[prop]);
15663
+ if (__getOwnPropSymbols$7)
15664
+ for (var prop of __getOwnPropSymbols$7(b)) {
15665
+ if (__propIsEnum$7.call(b, prop))
15666
+ __defNormalProp$a(a, prop, b[prop]);
14963
15667
  }
14964
15668
  return a;
14965
15669
  };
@@ -14967,16 +15671,16 @@ var LeafletMapAdapter = (function () {
14967
15671
  var __objRest$2 = (source, exclude) => {
14968
15672
  var target = {};
14969
15673
  for (var prop in source)
14970
- if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
15674
+ if (__hasOwnProp$7.call(source, prop) && exclude.indexOf(prop) < 0)
14971
15675
  target[prop] = source[prop];
14972
- if (source != null && __getOwnPropSymbols$6)
14973
- for (var prop of __getOwnPropSymbols$6(source)) {
14974
- if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
15676
+ if (source != null && __getOwnPropSymbols$7)
15677
+ for (var prop of __getOwnPropSymbols$7(source)) {
15678
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$7.call(source, prop))
14975
15679
  target[prop] = source[prop];
14976
15680
  }
14977
15681
  return target;
14978
15682
  };
14979
- var __publicField$6 = (obj, key, value) => __defNormalProp$9(obj, key + "" , value);
15683
+ var __publicField$6 = (obj, key, value) => __defNormalProp$a(obj, key + "" , value);
14980
15684
  class GeoJsonPaint {
14981
15685
  constructor(layer) {
14982
15686
  __publicField$6(this, "layer");
@@ -15058,7 +15762,7 @@ var LeafletMapAdapter = (function () {
15058
15762
  if (html) {
15059
15763
  element.innerHTML = html;
15060
15764
  }
15061
- const divIcon = new leafletSrcExports.DivIcon(__spreadProps$5(__spreadValues$6({
15765
+ const divIcon = new leafletSrcExports.DivIcon(__spreadProps$5(__spreadValues$7({
15062
15766
  className: ""
15063
15767
  }, toLIconOpt), {
15064
15768
  html: element
@@ -15084,7 +15788,7 @@ var LeafletMapAdapter = (function () {
15084
15788
  }
15085
15789
  return (_, latlng) => {
15086
15790
  const p = PAINT;
15087
- return new leafletSrcExports.CircleMarker(latlng, this.preparePaint(__spreadValues$6(__spreadValues$6({}, p), icon)));
15791
+ return new leafletSrcExports.CircleMarker(latlng, this.preparePaint(__spreadValues$7(__spreadValues$7({}, p), icon)));
15088
15792
  };
15089
15793
  }
15090
15794
  createPaintOptions(paint) {
@@ -15106,26 +15810,26 @@ var LeafletMapAdapter = (function () {
15106
15810
  }
15107
15811
  }
15108
15812
 
15109
- var __defProp$8 = Object.defineProperty;
15813
+ var __defProp$9 = Object.defineProperty;
15110
15814
  var __defProps$4 = Object.defineProperties;
15111
15815
  var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
15112
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
15113
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
15114
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
15115
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15116
- var __spreadValues$5 = (a, b) => {
15816
+ var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
15817
+ var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
15818
+ var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
15819
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15820
+ var __spreadValues$6 = (a, b) => {
15117
15821
  for (var prop in b || (b = {}))
15118
- if (__hasOwnProp$5.call(b, prop))
15119
- __defNormalProp$8(a, prop, b[prop]);
15120
- if (__getOwnPropSymbols$5)
15121
- for (var prop of __getOwnPropSymbols$5(b)) {
15122
- if (__propIsEnum$5.call(b, prop))
15123
- __defNormalProp$8(a, prop, b[prop]);
15822
+ if (__hasOwnProp$6.call(b, prop))
15823
+ __defNormalProp$9(a, prop, b[prop]);
15824
+ if (__getOwnPropSymbols$6)
15825
+ for (var prop of __getOwnPropSymbols$6(b)) {
15826
+ if (__propIsEnum$6.call(b, prop))
15827
+ __defNormalProp$9(a, prop, b[prop]);
15124
15828
  }
15125
15829
  return a;
15126
15830
  };
15127
15831
  var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
15128
- var __publicField$5 = (obj, key, value) => __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
15832
+ var __publicField$5 = (obj, key, value) => __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
15129
15833
  var __async = (__this, __arguments, generator) => {
15130
15834
  return new Promise((resolve, reject) => {
15131
15835
  var fulfilled = (value) => {
@@ -15173,7 +15877,7 @@ var LeafletMapAdapter = (function () {
15173
15877
  addLayer(options) {
15174
15878
  Object.assign(this.options, options);
15175
15879
  this.paint = options.paint;
15176
- this.layer = new leafletSrcExports.FeatureGroup([], __spreadProps$4(__spreadValues$5({}, options.nativeOptions), {
15880
+ this.layer = new leafletSrcExports.FeatureGroup([], __spreadProps$4(__spreadValues$6({}, options.nativeOptions), {
15177
15881
  pane: this.pane
15178
15882
  }));
15179
15883
  this.selectedPaint = options.selectedPaint;
@@ -15222,7 +15926,7 @@ var LeafletMapAdapter = (function () {
15222
15926
  }
15223
15927
  getSelected() {
15224
15928
  return this._selectedLayers.map((x) => {
15225
- return __spreadValues$5({
15929
+ return __spreadValues$6({
15226
15930
  target: this,
15227
15931
  feature: x.feature,
15228
15932
  layer: x
@@ -15241,14 +15945,14 @@ var LeafletMapAdapter = (function () {
15241
15945
  const filteredLayers = [];
15242
15946
  this._layers.forEach(({ feature, layer }) => {
15243
15947
  if (layer) {
15244
- const ok = fun ? fun(__spreadValues$5({
15948
+ const ok = fun ? fun(__spreadValues$6({
15245
15949
  target: this,
15246
15950
  feature,
15247
15951
  layer
15248
15952
  }, createFeaturePositionOptions(feature))) : true;
15249
15953
  if (ok) {
15250
15954
  layer_.addLayer(layer);
15251
- filteredLayers.push(__spreadValues$5({
15955
+ filteredLayers.push(__spreadValues$6({
15252
15956
  target: this,
15253
15957
  feature,
15254
15958
  layer
@@ -15269,7 +15973,7 @@ var LeafletMapAdapter = (function () {
15269
15973
  getLayers() {
15270
15974
  return this._layers.map(({ layer, feature }) => {
15271
15975
  const visible = layer && !!layer._map;
15272
- return __spreadValues$5({
15976
+ return __spreadValues$6({
15273
15977
  feature,
15274
15978
  layer,
15275
15979
  visible,
@@ -15387,13 +16091,13 @@ var LeafletMapAdapter = (function () {
15387
16091
  }
15388
16092
  }
15389
16093
  updatePaint(paint) {
15390
- this.paint = __spreadValues$5(__spreadValues$5({}, this.paint), paint);
16094
+ this.paint = __spreadValues$6(__spreadValues$6({}, this.paint), paint);
15391
16095
  for (const l of this._layers) {
15392
16096
  this._paint.setPaint(l, this.paint);
15393
16097
  }
15394
16098
  }
15395
16099
  updateSelectedPaint(paint) {
15396
- this.selectedPaint = __spreadValues$5(__spreadValues$5({}, this.selectedPaint), paint);
16100
+ this.selectedPaint = __spreadValues$6(__spreadValues$6({}, this.selectedPaint), paint);
15397
16101
  for (const l of this._selectedLayers) {
15398
16102
  this._paint.setPaint(l, this.selectedPaint);
15399
16103
  }
@@ -15410,7 +16114,7 @@ var LeafletMapAdapter = (function () {
15410
16114
  if (feature.properties && labelField) {
15411
16115
  message = feature.properties[labelField];
15412
16116
  } else if (label) {
15413
- message = label(__spreadValues$5(__spreadValues$5({
16117
+ message = label(__spreadValues$6(__spreadValues$6({
15414
16118
  target: this
15415
16119
  }, layerDef), createFeaturePositionOptions(feature)));
15416
16120
  }
@@ -15429,7 +16133,7 @@ var LeafletMapAdapter = (function () {
15429
16133
  autoPan,
15430
16134
  maxWidth,
15431
16135
  closeButton: closeButton_
15432
- } = __spreadValues$5({
16136
+ } = __spreadValues$6({
15433
16137
  minWidth: 300
15434
16138
  }, options);
15435
16139
  const closeButton = closeButton_ != null ? closeButton_ : !this.options.selectOnHover;
@@ -15445,7 +16149,7 @@ var LeafletMapAdapter = (function () {
15445
16149
  };
15446
16150
  let content;
15447
16151
  if (options.createPopupContent) {
15448
- content = yield options.createPopupContent(__spreadValues$5({
16152
+ content = yield options.createPopupContent(__spreadValues$6({
15449
16153
  layer,
15450
16154
  feature,
15451
16155
  target: this,
@@ -15523,9 +16227,9 @@ var LeafletMapAdapter = (function () {
15523
16227
  lopt = {
15524
16228
  style: (feature) => {
15525
16229
  if (feature) {
15526
- return this._paint.preparePaint(__spreadValues$5(__spreadValues$5({}, PAINT), paint(feature)));
16230
+ return this._paint.preparePaint(__spreadValues$6(__spreadValues$6({}, PAINT), paint(feature)));
15527
16231
  } else {
15528
- return this._paint.preparePaint(__spreadProps$4(__spreadValues$5({}, PAINT), { type: "path" }));
16232
+ return this._paint.preparePaint(__spreadProps$4(__spreadValues$6({}, PAINT), { type: "path" }));
15529
16233
  }
15530
16234
  }
15531
16235
  };
@@ -15541,7 +16245,7 @@ var LeafletMapAdapter = (function () {
15541
16245
  _onEachFeature(feature, layer) {
15542
16246
  const layer_ = this.layer;
15543
16247
  if (layer_) {
15544
- const def = __spreadValues$5({
16248
+ const def = __spreadValues$6({
15545
16249
  target: this,
15546
16250
  feature,
15547
16251
  layer
@@ -15576,7 +16280,7 @@ var LeafletMapAdapter = (function () {
15576
16280
  setTimeout(() => {
15577
16281
  if (popup) {
15578
16282
  this._openPopup(
15579
- __spreadValues$5({
16283
+ __spreadValues$6({
15580
16284
  target: this,
15581
16285
  layer,
15582
16286
  feature
@@ -15594,7 +16298,7 @@ var LeafletMapAdapter = (function () {
15594
16298
  leafletSrcExports.DomEvent.stopPropagation(e);
15595
16299
  const layer = e.target;
15596
16300
  const feature = layer.feature;
15597
- const def = __spreadValues$5({
16301
+ const def = __spreadValues$6({
15598
16302
  target: this,
15599
16303
  layer,
15600
16304
  feature
@@ -15627,7 +16331,7 @@ var LeafletMapAdapter = (function () {
15627
16331
  }
15628
16332
  if (this.options.onSelect) {
15629
16333
  const features = def.feature ? [def.feature] : [];
15630
- this.options.onSelect(__spreadValues$5({
16334
+ this.options.onSelect(__spreadValues$6({
15631
16335
  type,
15632
16336
  layer: this,
15633
16337
  features
@@ -15685,37 +16389,89 @@ var LeafletMapAdapter = (function () {
15685
16389
  }
15686
16390
  }
15687
16391
 
16392
+ var __defProp$8 = Object.defineProperty;
16393
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
16394
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
16395
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
16396
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
16397
+ var __spreadValues$5 = (a, b) => {
16398
+ for (var prop in b || (b = {}))
16399
+ if (__hasOwnProp$5.call(b, prop))
16400
+ __defNormalProp$8(a, prop, b[prop]);
16401
+ if (__getOwnPropSymbols$5)
16402
+ for (var prop of __getOwnPropSymbols$5(b)) {
16403
+ if (__propIsEnum$5.call(b, prop))
16404
+ __defNormalProp$8(a, prop, b[prop]);
16405
+ }
16406
+ return a;
16407
+ };
16408
+ function hasHeaders(headers) {
16409
+ return !!headers && Object.keys(headers).length > 0;
16410
+ }
16411
+ function normalizeLayerRequestOptions(request) {
16412
+ if (!request) {
16413
+ return void 0;
16414
+ }
16415
+ const normalized = __spreadValues$5({}, request);
16416
+ return hasLayerRequestOptions(normalized) ? normalized : void 0;
16417
+ }
16418
+ function getLayerRequestOptions(options) {
16419
+ const request = options == null ? void 0 : options.request;
16420
+ const headers = __spreadValues$5(__spreadValues$5({}, (options == null ? void 0 : options.headers) || {}), (request == null ? void 0 : request.headers) || {});
16421
+ const result = {};
16422
+ if (hasHeaders(headers)) {
16423
+ result.headers = headers;
16424
+ }
16425
+ if (options == null ? void 0 : options.withCredentials) {
16426
+ result.credentials = "include";
16427
+ }
16428
+ if ((request == null ? void 0 : request.credentials) !== void 0) {
16429
+ result.credentials = request.credentials;
16430
+ }
16431
+ if ((request == null ? void 0 : request.cache) !== void 0) {
16432
+ result.cache = request.cache;
16433
+ }
16434
+ return normalizeLayerRequestOptions(result);
16435
+ }
16436
+ function hasLayerRequestOptions(request) {
16437
+ return !!(request && (hasHeaders(request.headers) || request.credentials !== void 0 || request.cache !== void 0 && request.cache !== "default"));
16438
+ }
16439
+
15688
16440
  function callAjax({
15689
16441
  src,
15690
16442
  headers,
15691
- withCredentials
16443
+ withCredentials,
16444
+ request
15692
16445
  }) {
15693
- let abortFunc = () => {
15694
- };
15695
- const promise = new Promise((resolve, reject) => {
15696
- const xhr = new XMLHttpRequest();
15697
- xhr.open("GET", src);
15698
- xhr.responseType = "arraybuffer";
15699
- for (const h in headers) {
15700
- xhr.setRequestHeader(h, headers[h]);
16446
+ const layerRequest = getLayerRequestOptions({
16447
+ headers,
16448
+ request,
16449
+ withCredentials
16450
+ });
16451
+ const requestHeaders = (layerRequest == null ? void 0 : layerRequest.headers) || {};
16452
+ const controller = new AbortController();
16453
+ const promise = fetch(src, {
16454
+ cache: layerRequest == null ? void 0 : layerRequest.cache,
16455
+ credentials: layerRequest == null ? void 0 : layerRequest.credentials,
16456
+ headers: requestHeaders,
16457
+ signal: controller.signal
16458
+ }).then((response) => {
16459
+ if (!response.ok) {
16460
+ throw new Error(response.statusText);
15701
16461
  }
15702
- if (withCredentials) {
15703
- xhr.withCredentials = withCredentials;
16462
+ return response.blob();
16463
+ }).then((blob) => {
16464
+ const urlCreator = window.URL || window.webkitURL;
16465
+ return urlCreator.createObjectURL(blob);
16466
+ }).catch((er) => {
16467
+ if (er.name === "AbortError") {
16468
+ return "";
15704
16469
  }
15705
- xhr.onload = function() {
15706
- const arrayBufferView = new Uint8Array(this.response);
15707
- const blob = new Blob([arrayBufferView], { type: "image/png" });
15708
- const urlCreator = window.URL || window.webkitURL;
15709
- const imageUrl = urlCreator.createObjectURL(blob);
15710
- resolve(imageUrl);
15711
- };
15712
- xhr.onerror = reject;
15713
- xhr.send();
15714
- abortFunc = () => {
15715
- xhr.abort();
15716
- resolve("");
15717
- };
16470
+ throw er;
15718
16471
  });
16472
+ const abortFunc = () => {
16473
+ controller.abort();
16474
+ };
15719
16475
  return [promise, abortFunc];
15720
16476
  }
15721
16477
 
@@ -15824,7 +16580,7 @@ var LeafletMapAdapter = (function () {
15824
16580
  }
15825
16581
  _initImage() {
15826
16582
  super._initImage();
15827
- const { headers, withCredentials } = this.options;
16583
+ const { headers, request, withCredentials } = this.options;
15828
16584
  const img = this._image;
15829
16585
  const src = img.src;
15830
16586
  img.src = "";
@@ -15832,6 +16588,7 @@ var LeafletMapAdapter = (function () {
15832
16588
  const [promise, abortFunc] = callAjax({
15833
16589
  src,
15834
16590
  headers,
16591
+ request,
15835
16592
  withCredentials
15836
16593
  });
15837
16594
  promise.then((imgUrl) => {
@@ -15940,6 +16697,7 @@ var LeafletMapAdapter = (function () {
15940
16697
  opacity: 0,
15941
16698
  pane: this.options.pane,
15942
16699
  headers: this.options.headers,
16700
+ request: this.options.request,
15943
16701
  withCredentials: this.options.withCredentials
15944
16702
  });
15945
16703
  overlay.addTo(this._map);
@@ -16064,15 +16822,17 @@ var LeafletMapAdapter = (function () {
16064
16822
  const url = options && options.url;
16065
16823
  if (url) {
16066
16824
  const updateWmsParamsFromOpt = options.updateWmsParams;
16067
- this.layer = new ImageLayer(url, __spreadValues$4(__spreadValues$4(__spreadValues$4({
16825
+ const request = getLayerRequestOptions(options);
16826
+ this.layer = new ImageLayer(url, __spreadProps$3(__spreadValues$4(__spreadValues$4(__spreadValues$4({
16068
16827
  pane: this.pane,
16069
- headers: options.headers,
16070
16828
  setViewDelay: options.setViewDelay
16071
16829
  }, __spreadProps$3(__spreadValues$4({
16072
16830
  transparent: true
16073
16831
  }, options), {
16074
16832
  opacity: (_a = options.opacity) != null ? _a : void 0
16075
- })), options.params), options.nativeOptions));
16833
+ })), options.params), options.nativeOptions), {
16834
+ request
16835
+ }));
16076
16836
  if (updateWmsParamsFromOpt) {
16077
16837
  const updateWmsParams = this.layer.updateWmsParams;
16078
16838
  this.layer.updateWmsParams = function(map) {
@@ -16109,7 +16869,8 @@ var LeafletMapAdapter = (function () {
16109
16869
  const [promise, abortFunc] = callAjax({
16110
16870
  src,
16111
16871
  withCredentials: this.options.withCredentials,
16112
- headers: this.options.headers
16872
+ headers: this.options.headers,
16873
+ request: this.options.request
16113
16874
  });
16114
16875
  promise.then((response) => {
16115
16876
  tile.src = response;
@@ -16200,10 +16961,10 @@ var LeafletMapAdapter = (function () {
16200
16961
  tileLayerOptions.subdomains = opt.subdomains;
16201
16962
  }
16202
16963
  let layer;
16203
- if (opt.headers || opt.withCredentials) {
16964
+ const request = getLayerRequestOptions(opt);
16965
+ if (request) {
16204
16966
  layer = new TileLayer(url, __spreadProps$2(__spreadValues$3({}, tileLayerOptions), {
16205
- headers: opt.headers,
16206
- withCredentials: opt.withCredentials,
16967
+ request,
16207
16968
  setViewDelay: opt.setViewDelay
16208
16969
  }));
16209
16970
  } else {
@@ -16308,10 +17069,10 @@ var LeafletMapAdapter = (function () {
16308
17069
  transparent: true
16309
17070
  }, options.nativeOptions);
16310
17071
  let layer;
16311
- if (opt.headers || opt.withCredentials) {
17072
+ const request = getLayerRequestOptions(opt);
17073
+ if (request) {
16312
17074
  layer = new WmsLayer(url, __spreadProps(__spreadValues$1({}, layerOptions), {
16313
- headers: opt.headers,
16314
- withCredentials: opt.withCredentials
17075
+ request
16315
17076
  }));
16316
17077
  } else {
16317
17078
  layer = new leafletSrcExports.TileLayer.WMS(url, layerOptions);
@@ -16354,6 +17115,7 @@ var LeafletMapAdapter = (function () {
16354
17115
  __publicField(this, "emitter", new EventEmitter());
16355
17116
  __publicField(this, "map");
16356
17117
  __publicField(this, "_resizeObserver");
17118
+ __publicField(this, "_controlContainer");
16357
17119
  __publicField(this, "_unselectCb", []);
16358
17120
  __publicField(this, "_universalEvents", [
16359
17121
  "move",
@@ -16392,6 +17154,7 @@ var LeafletMapAdapter = (function () {
16392
17154
  this._updateMinZoomForBounds(minZoom);
16393
17155
  this._watchSizeChangeToUpdateMinZoom();
16394
17156
  const defPane = this.map.createPane("order-0");
17157
+ this._controlContainer = new LeafletControlContainer(this.map);
16395
17158
  this.map._addUnselectCb = (def) => {
16396
17159
  this._addUnselectCb(def);
16397
17160
  };
@@ -16404,12 +17167,19 @@ var LeafletMapAdapter = (function () {
16404
17167
  if (this.map) {
16405
17168
  this.map.remove();
16406
17169
  }
17170
+ if (this._controlContainer) {
17171
+ this._controlContainer.detach();
17172
+ this._controlContainer = void 0;
17173
+ }
16407
17174
  this._stopWatchSizeChangeToUpdateMinZoom();
16408
17175
  }
16409
17176
  getContainer() {
16410
17177
  return this.map && this.map.getContainer();
16411
17178
  }
16412
17179
  getControlContainer() {
17180
+ if (this._controlContainer) {
17181
+ return this._controlContainer.getContainer();
17182
+ }
16413
17183
  const controlContainer = this.map && this.map._controlContainer;
16414
17184
  if (controlContainer) {
16415
17185
  return controlContainer;
@@ -16523,16 +17293,17 @@ var LeafletMapAdapter = (function () {
16523
17293
  createButtonControl(options) {
16524
17294
  return createButtonControl(options, this);
16525
17295
  }
16526
- addControl(control, position) {
16527
- control.options.position = position.replace("-", "");
16528
- if (this.map) {
16529
- this.map.addControl(control);
16530
- return control;
17296
+ createToggleControl(options) {
17297
+ return createToggleControl(options, this);
17298
+ }
17299
+ addControl(control, position, options) {
17300
+ if (this._controlContainer) {
17301
+ return this._controlContainer.addControl(control, position, options);
16531
17302
  }
16532
17303
  }
16533
17304
  removeControl(control) {
16534
- if (this.map) {
16535
- this.map.removeControl(control);
17305
+ if (this._controlContainer) {
17306
+ this._controlContainer.removeControl(control);
16536
17307
  }
16537
17308
  }
16538
17309
  removeLayer(layer) {