@nextgis/leaflet-map-adapter 3.0.0 → 4.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +4 -2
- package/lib/leaflet-map-adapter.css +1 -0
- package/lib/leaflet-map-adapter.esm-browser.js +1718 -1004
- package/lib/leaflet-map-adapter.esm-browser.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-browser.prod.js +2 -2
- package/lib/leaflet-map-adapter.esm-browser.prod.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-bundler.js +20 -84
- package/lib/leaflet-map-adapter.esm-bundler.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-bundler.prod.js +1 -1
- package/lib/leaflet-map-adapter.esm-bundler.prod.js.map +1 -1
- package/lib/leaflet-map-adapter.global.js +1718 -1004
- package/lib/leaflet-map-adapter.global.js.map +1 -1
- package/lib/leaflet-map-adapter.global.prod.js +2 -2
- package/lib/leaflet-map-adapter.global.prod.js.map +1 -1
- package/package.json +4 -3
|
@@ -1,474 +1,599 @@
|
|
|
1
|
-
/** Bundle of @nextgis/leaflet-map-adapter; version:
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
/** Bundle of @nextgis/leaflet-map-adapter; version: 4.0.0-alpha.0; author: NextGIS */
|
|
2
|
+
function getElement(el) {
|
|
3
|
+
if (typeof el === "string") {
|
|
4
|
+
let el_ = document.getElementById(el);
|
|
5
|
+
if (!el_) {
|
|
6
|
+
try {
|
|
7
|
+
el_ = document.querySelector(el);
|
|
8
|
+
} catch (e) {
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return el_ || void 0;
|
|
12
|
+
}
|
|
13
|
+
return el;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
var __defProp$g = Object.defineProperty;
|
|
17
|
+
var __defProps$8 = Object.defineProperties;
|
|
18
|
+
var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
|
|
19
|
+
var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
|
|
20
|
+
var __hasOwnProp$b = Object.prototype.hasOwnProperty;
|
|
21
|
+
var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
|
|
22
|
+
var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
23
|
+
var __spreadValues$b = (a, b) => {
|
|
24
|
+
for (var prop in b || (b = {}))
|
|
25
|
+
if (__hasOwnProp$b.call(b, prop))
|
|
26
|
+
__defNormalProp$g(a, prop, b[prop]);
|
|
27
|
+
if (__getOwnPropSymbols$b)
|
|
28
|
+
for (var prop of __getOwnPropSymbols$b(b)) {
|
|
29
|
+
if (__propIsEnum$b.call(b, prop))
|
|
30
|
+
__defNormalProp$g(a, prop, b[prop]);
|
|
31
|
+
}
|
|
32
|
+
return a;
|
|
33
|
+
};
|
|
34
|
+
var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
|
|
35
|
+
const controlOptions = /* @__PURE__ */ new WeakMap();
|
|
36
|
+
function resolveControlOptions(options = {}) {
|
|
37
|
+
var _a;
|
|
38
|
+
return __spreadProps$8(__spreadValues$b({}, options), {
|
|
39
|
+
margin: (_a = options.margin) != null ? _a : options.bar
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function setControlOptions(control, options = {}) {
|
|
43
|
+
controlOptions.set(control, resolveControlOptions(options));
|
|
44
|
+
}
|
|
45
|
+
function getControlOptions(control) {
|
|
46
|
+
return control ? controlOptions.get(control) : void 0;
|
|
47
|
+
}
|
|
27
48
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
49
|
+
var __defProp$f = Object.defineProperty;
|
|
50
|
+
var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
51
|
+
var __publicField$a = (obj, key, value) => __defNormalProp$f(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
52
|
+
class ControlContainer {
|
|
53
|
+
constructor(opt = {}) {
|
|
54
|
+
__publicField$a(this, "classPrefix", "webmap");
|
|
55
|
+
__publicField$a(this, "addClass");
|
|
56
|
+
__publicField$a(this, "map");
|
|
57
|
+
__publicField$a(this, "wrapperClass");
|
|
58
|
+
__publicField$a(this, "ownsContainer");
|
|
59
|
+
__publicField$a(this, "_container");
|
|
60
|
+
__publicField$a(this, "_positionsContainers");
|
|
61
|
+
__publicField$a(this, "_targets", /* @__PURE__ */ new Set());
|
|
62
|
+
__publicField$a(this, "_idContainers", /* @__PURE__ */ new Map());
|
|
63
|
+
__publicField$a(this, "_pendingChildren", /* @__PURE__ */ new Map());
|
|
64
|
+
__publicField$a(this, "_orders", /* @__PURE__ */ new WeakMap());
|
|
65
|
+
__publicField$a(this, "_targetOptions", /* @__PURE__ */ new WeakMap());
|
|
66
|
+
__publicField$a(this, "_switchGroups", /* @__PURE__ */ new WeakMap());
|
|
67
|
+
__publicField$a(this, "_switchBindings", /* @__PURE__ */ new WeakMap());
|
|
68
|
+
this.classPrefix = opt.classPrefix || this.classPrefix;
|
|
69
|
+
this.addClass = opt.addClass;
|
|
70
|
+
this.map = opt.map;
|
|
71
|
+
this.wrapperClass = opt.wrapperClass;
|
|
72
|
+
const externalPositions = [
|
|
73
|
+
"top-right",
|
|
74
|
+
"top-left",
|
|
75
|
+
"bottom-right",
|
|
76
|
+
"bottom-left"
|
|
77
|
+
];
|
|
78
|
+
const positionContainers = externalPositions.some(
|
|
79
|
+
(position) => {
|
|
80
|
+
var _a;
|
|
81
|
+
return !!((_a = opt.positionContainers) == null ? void 0 : _a[position]);
|
|
82
|
+
}
|
|
83
|
+
) ? opt.positionContainers : void 0;
|
|
84
|
+
this.ownsContainer = !opt.container && !positionContainers;
|
|
85
|
+
const { element, positionsContainers } = this.createContainerElement(
|
|
86
|
+
opt.container,
|
|
87
|
+
positionContainers
|
|
88
|
+
);
|
|
89
|
+
this._container = element;
|
|
90
|
+
this._positionsContainers = positionsContainers;
|
|
33
91
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
92
|
+
addTo(el) {
|
|
93
|
+
if (!this.ownsContainer) {
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
const el_ = getElement(el);
|
|
97
|
+
if (el_) {
|
|
98
|
+
el_.appendChild(this._container);
|
|
99
|
+
}
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
detach() {
|
|
103
|
+
if (!this.ownsContainer) {
|
|
104
|
+
Array.from(this._targets).forEach((target) => this.removeTarget(target));
|
|
105
|
+
this._pendingChildren.clear();
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const parent = this._container.parentElement;
|
|
109
|
+
if (parent) {
|
|
110
|
+
parent.removeChild(this._container);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
getContainer() {
|
|
114
|
+
return this._container;
|
|
115
|
+
}
|
|
116
|
+
getPositionContainer(position) {
|
|
117
|
+
return this._positionsContainers[position];
|
|
118
|
+
}
|
|
119
|
+
newPositionContainer(position, order = 0, control) {
|
|
120
|
+
var _a;
|
|
121
|
+
const newContainer = document.createElement("div");
|
|
122
|
+
newContainer.className = `${this.classPrefix}-ctrl-wrapper` + (this.wrapperClass ? " " + this.wrapperClass : "");
|
|
123
|
+
if ((_a = getControlOptions(control)) == null ? void 0 : _a.margin) {
|
|
124
|
+
newContainer.classList.add(`${this.classPrefix}-ctrl-margin`);
|
|
125
|
+
}
|
|
126
|
+
this.append(newContainer, position, order, control);
|
|
127
|
+
return newContainer;
|
|
128
|
+
}
|
|
129
|
+
addControl(control, position, options = {}) {
|
|
130
|
+
const controlContainer = control.onAdd(this.map);
|
|
131
|
+
if (controlContainer instanceof HTMLElement) {
|
|
132
|
+
const target = this.newPositionContainer(
|
|
133
|
+
position,
|
|
134
|
+
options.order,
|
|
135
|
+
control
|
|
136
|
+
);
|
|
137
|
+
if (target) {
|
|
138
|
+
target.appendChild(controlContainer);
|
|
139
|
+
if (options.id) {
|
|
140
|
+
this.registerIDContainer(options.id, controlContainer, control);
|
|
141
|
+
}
|
|
142
|
+
return target;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
append(element, position, order = 0, control) {
|
|
147
|
+
const node = this._normalizeElement(element);
|
|
148
|
+
if (!node) return;
|
|
149
|
+
const positionContainer = this._resolveTargetContainer(position);
|
|
150
|
+
if (positionContainer) {
|
|
151
|
+
this._insertSorted(positionContainer, node, order);
|
|
152
|
+
this._registerSwitchControl(node, control, positionContainer);
|
|
153
|
+
return positionContainer;
|
|
154
|
+
} else if (typeof position !== "string") {
|
|
155
|
+
this._appendPending(position.inside, node, order, control);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
registerIDContainer(id, controlRoot, control) {
|
|
159
|
+
this._idContainers.set(id, controlRoot);
|
|
160
|
+
this._registerTargetOptions(controlRoot, control);
|
|
161
|
+
this._flushPending(id, controlRoot);
|
|
162
|
+
}
|
|
163
|
+
unregisterIDContainer(id) {
|
|
164
|
+
const controlRoot = this._idContainers.get(id);
|
|
165
|
+
if (controlRoot) {
|
|
166
|
+
this._targetOptions.delete(controlRoot);
|
|
167
|
+
}
|
|
168
|
+
this._idContainers.delete(id);
|
|
169
|
+
this._pendingChildren.delete(id);
|
|
170
|
+
}
|
|
171
|
+
removeTarget(target) {
|
|
172
|
+
const parent = target.parentElement;
|
|
173
|
+
if (parent) {
|
|
174
|
+
parent.removeChild(target);
|
|
175
|
+
}
|
|
176
|
+
this._unregisterSwitchControl(target);
|
|
177
|
+
this._removePending(target);
|
|
178
|
+
this._targets.delete(target);
|
|
179
|
+
}
|
|
180
|
+
createContainerElement(container, positionContainers) {
|
|
181
|
+
const element = container || document.createElement("div");
|
|
182
|
+
if (!container) {
|
|
183
|
+
element.className = `${this.classPrefix}-control-container` + (this.addClass ? " " + this.addClass : "");
|
|
184
|
+
}
|
|
185
|
+
const positionsContainers = {};
|
|
186
|
+
const positions = [
|
|
187
|
+
"top-right",
|
|
188
|
+
"top-left",
|
|
189
|
+
"bottom-right",
|
|
190
|
+
"bottom-left"
|
|
191
|
+
];
|
|
192
|
+
positions.forEach((x) => {
|
|
193
|
+
const positionContainer = (positionContainers == null ? void 0 : positionContainers[x]) || this._createPositionContainer(x);
|
|
194
|
+
positionsContainers[x] = positionContainer;
|
|
195
|
+
if (!(positionContainers == null ? void 0 : positionContainers[x])) {
|
|
196
|
+
element.appendChild(positionContainer);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
return { element, positionsContainers };
|
|
200
|
+
}
|
|
201
|
+
_createPositionContainer(position) {
|
|
202
|
+
const positionContainer = document.createElement("div");
|
|
203
|
+
positionContainer.className = `${this.classPrefix}-ctrl-${position}`;
|
|
204
|
+
return positionContainer;
|
|
205
|
+
}
|
|
206
|
+
_resolveTargetContainer(position) {
|
|
207
|
+
return typeof position === "string" ? this._positionsContainers[position] : this._idContainers.get(position.inside);
|
|
208
|
+
}
|
|
209
|
+
_normalizeElement(element) {
|
|
210
|
+
if (typeof element !== "string") {
|
|
211
|
+
return element;
|
|
212
|
+
}
|
|
213
|
+
const template = document.createElement("template");
|
|
214
|
+
template.innerHTML = element.trim();
|
|
215
|
+
return template.content.firstElementChild;
|
|
216
|
+
}
|
|
217
|
+
_insertSorted(positionContainer, element, order) {
|
|
218
|
+
this._orders.set(element, order);
|
|
219
|
+
element.style.order = String(order);
|
|
220
|
+
const isBottomPosition = this._isBottomPositionContainer(positionContainer);
|
|
221
|
+
const children = Array.from(positionContainer.children);
|
|
222
|
+
const before = children.find((child) => {
|
|
223
|
+
var _a;
|
|
224
|
+
if (child === element) {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
const value = (_a = this._orders.get(child)) != null ? _a : Number.POSITIVE_INFINITY;
|
|
228
|
+
return isBottomPosition ? value <= order : value > order;
|
|
229
|
+
});
|
|
230
|
+
if (before) {
|
|
231
|
+
positionContainer.insertBefore(element, before);
|
|
232
|
+
} else if (element.parentElement === positionContainer) {
|
|
233
|
+
return;
|
|
234
|
+
} else {
|
|
235
|
+
positionContainer.appendChild(element);
|
|
236
|
+
}
|
|
237
|
+
this._targets.add(element);
|
|
238
|
+
}
|
|
239
|
+
_isBottomPositionContainer(element) {
|
|
240
|
+
return element === this._positionsContainers["bottom-left"] || element === this._positionsContainers["bottom-right"];
|
|
241
|
+
}
|
|
242
|
+
_appendPending(parentId, element, order, control) {
|
|
243
|
+
const parent = element.parentElement;
|
|
244
|
+
if (parent) {
|
|
245
|
+
parent.removeChild(element);
|
|
246
|
+
}
|
|
247
|
+
const pending = this._pendingChildren.get(parentId) || [];
|
|
248
|
+
pending.push({ element, order, control });
|
|
249
|
+
pending.sort((a, b) => a.order - b.order);
|
|
250
|
+
this._pendingChildren.set(parentId, pending);
|
|
251
|
+
this._targets.add(element);
|
|
252
|
+
}
|
|
253
|
+
_flushPending(parentId, target) {
|
|
254
|
+
const pending = this._pendingChildren.get(parentId);
|
|
255
|
+
if (!pending) return;
|
|
256
|
+
for (const { element, order, control } of pending) {
|
|
257
|
+
this._insertSorted(target, element, order);
|
|
258
|
+
this._registerSwitchControl(element, control, target);
|
|
259
|
+
}
|
|
260
|
+
this._pendingChildren.delete(parentId);
|
|
261
|
+
}
|
|
262
|
+
_removePending(target) {
|
|
263
|
+
this._pendingChildren.forEach((children, parentId) => {
|
|
264
|
+
const filtered = children.filter(({ element }) => element !== target);
|
|
265
|
+
if (filtered.length) {
|
|
266
|
+
this._pendingChildren.set(parentId, filtered);
|
|
267
|
+
} else {
|
|
268
|
+
this._pendingChildren.delete(parentId);
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
_registerSwitchControl(element, control, target) {
|
|
273
|
+
if (!this._isSwitchToggleControl(control)) return;
|
|
274
|
+
this._unregisterSwitchControl(element);
|
|
275
|
+
const groupName = typeof control.switch === "string" ? control.switch : "default";
|
|
276
|
+
const group = this._getSwitchGroup(target, groupName);
|
|
277
|
+
const hadDisableOnSecondClick = Object.prototype.hasOwnProperty.call(
|
|
278
|
+
control,
|
|
279
|
+
"disableOnSecondClick"
|
|
280
|
+
);
|
|
281
|
+
const previousDisableOnSecondClick = control.disableOnSecondClick;
|
|
282
|
+
const targetDisableOnSecondClick = control.disableOnSecondClick === void 0 ? this._getTargetDisableOnSecondClick(target) : void 0;
|
|
283
|
+
if (targetDisableOnSecondClick !== void 0) {
|
|
284
|
+
control.disableOnSecondClick = targetDisableOnSecondClick;
|
|
285
|
+
}
|
|
286
|
+
group.add(control);
|
|
287
|
+
const unsubscribe = control.onStatusChange((status) => {
|
|
288
|
+
if (status) {
|
|
289
|
+
this._disableSwitchSiblings(control, group);
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
this._switchBindings.set(element, {
|
|
293
|
+
control,
|
|
294
|
+
group,
|
|
295
|
+
unsubscribe,
|
|
296
|
+
hadDisableOnSecondClick,
|
|
297
|
+
previousDisableOnSecondClick
|
|
298
|
+
});
|
|
299
|
+
if (control.getStatus()) {
|
|
300
|
+
this._disableSwitchSiblings(control, group);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
_unregisterSwitchControl(element) {
|
|
304
|
+
const binding = this._switchBindings.get(element);
|
|
305
|
+
if (binding) {
|
|
306
|
+
binding.unsubscribe();
|
|
307
|
+
binding.group.delete(binding.control);
|
|
308
|
+
if (binding.hadDisableOnSecondClick) {
|
|
309
|
+
binding.control.disableOnSecondClick = binding.previousDisableOnSecondClick;
|
|
310
|
+
} else {
|
|
311
|
+
delete binding.control.disableOnSecondClick;
|
|
312
|
+
}
|
|
313
|
+
this._switchBindings.delete(element);
|
|
314
|
+
}
|
|
315
|
+
Array.from(element.children).forEach((child) => {
|
|
316
|
+
if (child instanceof HTMLElement) {
|
|
317
|
+
this._unregisterSwitchControl(child);
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
_getSwitchGroup(target, groupName) {
|
|
322
|
+
let targetGroups = this._switchGroups.get(target);
|
|
323
|
+
if (!targetGroups) {
|
|
324
|
+
targetGroups = /* @__PURE__ */ new Map();
|
|
325
|
+
this._switchGroups.set(target, targetGroups);
|
|
326
|
+
}
|
|
327
|
+
let group = targetGroups.get(groupName);
|
|
328
|
+
if (!group) {
|
|
329
|
+
group = /* @__PURE__ */ new Set();
|
|
330
|
+
targetGroups.set(groupName, group);
|
|
331
|
+
}
|
|
332
|
+
return group;
|
|
333
|
+
}
|
|
334
|
+
_disableSwitchSiblings(activeControl, group) {
|
|
335
|
+
group.forEach((control) => {
|
|
336
|
+
if (control !== activeControl && control.getStatus()) {
|
|
337
|
+
control.onClick(false);
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
_getTargetDisableOnSecondClick(target) {
|
|
342
|
+
var _a;
|
|
343
|
+
return (_a = this._targetOptions.get(target)) == null ? void 0 : _a.disableOnSecondClick;
|
|
344
|
+
}
|
|
345
|
+
_isSwitchToggleControl(control) {
|
|
346
|
+
const toggle = control;
|
|
347
|
+
return !!((toggle == null ? void 0 : toggle.switch) && typeof toggle.onStatusChange === "function" && typeof toggle.getStatus === "function" && typeof toggle.onClick === "function");
|
|
348
|
+
}
|
|
349
|
+
_registerTargetOptions(target, control) {
|
|
350
|
+
const options = getControlOptions(control) || getControlOptions(target);
|
|
351
|
+
if (options) {
|
|
352
|
+
this._targetOptions.set(target, options);
|
|
353
|
+
} else {
|
|
354
|
+
this._targetOptions.delete(target);
|
|
355
|
+
}
|
|
38
356
|
}
|
|
39
|
-
|
|
40
|
-
this._maxListeners = this._maxListeners || undefined;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// Obviously not all Emitters should be limited to 10. This function allows
|
|
44
|
-
// that to be increased. Set to zero for unlimited.
|
|
45
|
-
EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
|
|
46
|
-
if (typeof n !== 'number' || n < 0 || isNaN(n))
|
|
47
|
-
throw new TypeError('"n" argument must be a positive number');
|
|
48
|
-
this._maxListeners = n;
|
|
49
|
-
return this;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
function $getMaxListeners(that) {
|
|
53
|
-
if (that._maxListeners === undefined)
|
|
54
|
-
return EventEmitter.defaultMaxListeners;
|
|
55
|
-
return that._maxListeners;
|
|
56
357
|
}
|
|
57
358
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
var listeners = arrayClone(handler, len);
|
|
73
|
-
for (var i = 0; i < len; ++i)
|
|
74
|
-
listeners[i].call(self);
|
|
359
|
+
const STOP_PROPAGATION_EVENTS = [
|
|
360
|
+
"wheel",
|
|
361
|
+
"click",
|
|
362
|
+
"mouseup",
|
|
363
|
+
"touchend",
|
|
364
|
+
"dblclick",
|
|
365
|
+
"pointerup",
|
|
366
|
+
"mousedown",
|
|
367
|
+
"touchstart",
|
|
368
|
+
"pointerdown"
|
|
369
|
+
];
|
|
370
|
+
function addClasses(element, classes) {
|
|
371
|
+
if (classes) {
|
|
372
|
+
classes.split(" ").filter(Boolean).forEach((x) => element.classList.add(x));
|
|
75
373
|
}
|
|
76
374
|
}
|
|
77
|
-
function
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
else {
|
|
81
|
-
var len = handler.length;
|
|
82
|
-
var listeners = arrayClone(handler, len);
|
|
83
|
-
for (var i = 0; i < len; ++i)
|
|
84
|
-
listeners[i].call(self, arg1);
|
|
375
|
+
function removeElement(element) {
|
|
376
|
+
if (element == null ? void 0 : element.parentNode) {
|
|
377
|
+
element.parentNode.removeChild(element);
|
|
85
378
|
}
|
|
86
379
|
}
|
|
87
|
-
function
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
380
|
+
function stopPropagation(event) {
|
|
381
|
+
event.stopPropagation();
|
|
382
|
+
}
|
|
383
|
+
function preventMapEventPropagation(element) {
|
|
384
|
+
STOP_PROPAGATION_EVENTS.forEach((eventName) => {
|
|
385
|
+
element.addEventListener(eventName, stopPropagation);
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
function getAlignValue(align) {
|
|
389
|
+
if (align === "start") return "flex-start";
|
|
390
|
+
if (align === "end") return "flex-end";
|
|
391
|
+
return align;
|
|
392
|
+
}
|
|
393
|
+
function isZeroGap(gap) {
|
|
394
|
+
if (typeof gap === "number") {
|
|
395
|
+
return gap === 0;
|
|
95
396
|
}
|
|
397
|
+
if (typeof gap === "string") {
|
|
398
|
+
return gap.trim().split(/\s+/).every((x) => /^0(?:\.0+)?(?:[a-z%]+)?$/i.test(x));
|
|
399
|
+
}
|
|
400
|
+
return false;
|
|
96
401
|
}
|
|
97
|
-
function
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
402
|
+
function createControlContainer(options = {}) {
|
|
403
|
+
const resolvedOptions = resolveControlOptions(options);
|
|
404
|
+
const element = document.createElement("div");
|
|
405
|
+
element.className = "webmap-ctrl";
|
|
406
|
+
if (resolvedOptions.bar) {
|
|
407
|
+
element.classList.add("webmap-ctrl-group");
|
|
408
|
+
}
|
|
409
|
+
if (resolvedOptions.margin) {
|
|
410
|
+
element.classList.add("webmap-ctrl-margin");
|
|
411
|
+
}
|
|
412
|
+
const orientation = resolvedOptions.orientation || resolvedOptions.direction;
|
|
413
|
+
if (orientation) {
|
|
414
|
+
element.classList.add(`webmap-ctrl-${orientation}`);
|
|
105
415
|
}
|
|
416
|
+
if (resolvedOptions.gap !== void 0) {
|
|
417
|
+
const gap = typeof resolvedOptions.gap === "number" ? `${resolvedOptions.gap}px` : resolvedOptions.gap;
|
|
418
|
+
element.style.setProperty("--webmap-ctrl-gap", gap);
|
|
419
|
+
if (isZeroGap(resolvedOptions.gap)) {
|
|
420
|
+
element.classList.add("webmap-ctrl-gapless");
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
const align = getAlignValue(resolvedOptions.align);
|
|
424
|
+
if (align) {
|
|
425
|
+
element.style.setProperty("--webmap-ctrl-align", align);
|
|
426
|
+
}
|
|
427
|
+
addClasses(element, resolvedOptions.addClass);
|
|
428
|
+
preventMapEventPropagation(element);
|
|
429
|
+
return element;
|
|
106
430
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
var len = handler.length;
|
|
113
|
-
var listeners = arrayClone(handler, len);
|
|
114
|
-
for (var i = 0; i < len; ++i)
|
|
115
|
-
listeners[i].apply(self, args);
|
|
431
|
+
function appendHtml(element, html) {
|
|
432
|
+
if (html instanceof HTMLElement) {
|
|
433
|
+
element.appendChild(html);
|
|
434
|
+
} else if (typeof html === "string") {
|
|
435
|
+
element.innerHTML = html;
|
|
116
436
|
}
|
|
117
437
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
438
|
+
function createControlElement(control, options = {}, map) {
|
|
439
|
+
const element = createControlContainer(options);
|
|
440
|
+
setControlOptions(element, options);
|
|
441
|
+
const content = control.onAdd(map);
|
|
442
|
+
if (content) {
|
|
443
|
+
element.appendChild(content);
|
|
444
|
+
}
|
|
445
|
+
return element;
|
|
446
|
+
}
|
|
447
|
+
function createButtonControlContent(options) {
|
|
448
|
+
let button;
|
|
449
|
+
const onClick = (event) => {
|
|
450
|
+
event.preventDefault();
|
|
451
|
+
event.stopPropagation();
|
|
452
|
+
options.onClick();
|
|
453
|
+
};
|
|
454
|
+
const buttonControl = {
|
|
455
|
+
onAdd() {
|
|
456
|
+
button = document.createElement("button");
|
|
457
|
+
button.type = "button";
|
|
458
|
+
button.className = "webmap-ctrl-button";
|
|
459
|
+
addClasses(button, options.addClass);
|
|
460
|
+
if (options.title) {
|
|
461
|
+
button.title = options.title;
|
|
462
|
+
button.setAttribute("aria-label", options.title);
|
|
463
|
+
}
|
|
464
|
+
appendHtml(button, options.html);
|
|
465
|
+
button.addEventListener("click", onClick);
|
|
466
|
+
return button;
|
|
467
|
+
},
|
|
468
|
+
onRemove() {
|
|
469
|
+
if (button) {
|
|
470
|
+
button.removeEventListener("click", onClick);
|
|
471
|
+
removeElement(button);
|
|
472
|
+
button = void 0;
|
|
473
|
+
}
|
|
474
|
+
},
|
|
475
|
+
getContainer() {
|
|
476
|
+
return button;
|
|
148
477
|
}
|
|
149
|
-
|
|
478
|
+
};
|
|
479
|
+
buttonControl.remove = () => {
|
|
480
|
+
buttonControl.onRemove();
|
|
481
|
+
};
|
|
482
|
+
return buttonControl;
|
|
483
|
+
}
|
|
484
|
+
function createToggleControlContent(options) {
|
|
485
|
+
const link = document.createElement("div");
|
|
486
|
+
const statusListeners = /* @__PURE__ */ new Set();
|
|
487
|
+
let status = false;
|
|
488
|
+
if (options.getStatus) {
|
|
489
|
+
status = options.getStatus();
|
|
490
|
+
} else if (options.status) {
|
|
491
|
+
status = options.status;
|
|
150
492
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
return false;
|
|
156
|
-
|
|
157
|
-
var isFn = typeof handler === 'function';
|
|
158
|
-
len = arguments.length;
|
|
159
|
-
switch (len) {
|
|
160
|
-
// fast cases
|
|
161
|
-
case 1:
|
|
162
|
-
emitNone(handler, isFn, this);
|
|
163
|
-
break;
|
|
164
|
-
case 2:
|
|
165
|
-
emitOne(handler, isFn, this, arguments[1]);
|
|
166
|
-
break;
|
|
167
|
-
case 3:
|
|
168
|
-
emitTwo(handler, isFn, this, arguments[1], arguments[2]);
|
|
169
|
-
break;
|
|
170
|
-
case 4:
|
|
171
|
-
emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
|
|
172
|
-
break;
|
|
173
|
-
// slower
|
|
174
|
-
default:
|
|
175
|
-
args = new Array(len - 1);
|
|
176
|
-
for (i = 1; i < len; i++)
|
|
177
|
-
args[i - 1] = arguments[i];
|
|
178
|
-
emitMany(handler, isFn, this, args);
|
|
493
|
+
const title = options.title || "";
|
|
494
|
+
const html = options.html;
|
|
495
|
+
function notifyStatusChange(control) {
|
|
496
|
+
statusListeners.forEach((listener) => listener(status, control));
|
|
179
497
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (typeof listener !== 'function')
|
|
190
|
-
throw new TypeError('"listener" argument must be a function');
|
|
191
|
-
|
|
192
|
-
events = target._events;
|
|
193
|
-
if (!events) {
|
|
194
|
-
events = target._events = new EventHandlers();
|
|
195
|
-
target._eventsCount = 0;
|
|
196
|
-
} else {
|
|
197
|
-
// To avoid recursion in the case that type === "newListener"! Before
|
|
198
|
-
// adding it to the listeners, first emit "newListener".
|
|
199
|
-
if (events.newListener) {
|
|
200
|
-
target.emit('newListener', type,
|
|
201
|
-
listener.listener ? listener.listener : listener);
|
|
202
|
-
|
|
203
|
-
// Re-assign `events` because a newListener handler could have caused the
|
|
204
|
-
// this._events to be assigned to a new object
|
|
205
|
-
events = target._events;
|
|
498
|
+
function setTitle() {
|
|
499
|
+
if (title) {
|
|
500
|
+
if (typeof title === "string") {
|
|
501
|
+
link.title = title;
|
|
502
|
+
} else {
|
|
503
|
+
link.title = status ? title.on : title.off;
|
|
504
|
+
}
|
|
505
|
+
link.setAttribute("aria-label", link.title);
|
|
206
506
|
}
|
|
207
|
-
existing = events[type];
|
|
208
507
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
} else {
|
|
215
|
-
if (typeof existing === 'function') {
|
|
216
|
-
// Adding the second element, need to change to array.
|
|
217
|
-
existing = events[type] = prepend ? [listener, existing] :
|
|
218
|
-
[existing, listener];
|
|
219
|
-
} else {
|
|
220
|
-
// If we've already got an array, just append.
|
|
221
|
-
if (prepend) {
|
|
222
|
-
existing.unshift(listener);
|
|
508
|
+
function setHtml() {
|
|
509
|
+
if (html) {
|
|
510
|
+
link.innerHTML = "";
|
|
511
|
+
if (typeof html === "string" || html instanceof HTMLElement) {
|
|
512
|
+
appendHtml(link, html);
|
|
223
513
|
} else {
|
|
224
|
-
|
|
514
|
+
appendHtml(link, status ? html.on : html.off);
|
|
225
515
|
}
|
|
226
516
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
existing.length + ' ' + type + ' listeners added. ' +
|
|
235
|
-
'Use emitter.setMaxListeners() to increase limit');
|
|
236
|
-
w.name = 'MaxListenersExceededWarning';
|
|
237
|
-
w.emitter = target;
|
|
238
|
-
w.type = type;
|
|
239
|
-
w.count = existing.length;
|
|
240
|
-
emitWarning(w);
|
|
517
|
+
}
|
|
518
|
+
function setClasses(classes, impact) {
|
|
519
|
+
classes.split(" ").filter(Boolean).forEach((x) => {
|
|
520
|
+
if (impact) {
|
|
521
|
+
link.classList.add(x);
|
|
522
|
+
} else {
|
|
523
|
+
link.classList.remove(x);
|
|
241
524
|
}
|
|
242
|
-
}
|
|
525
|
+
});
|
|
243
526
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
EventEmitter.prototype.addListener = function addListener(type, listener) {
|
|
251
|
-
return _addListener(this, type, listener, false);
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
|
255
|
-
|
|
256
|
-
EventEmitter.prototype.prependListener =
|
|
257
|
-
function prependListener(type, listener) {
|
|
258
|
-
return _addListener(this, type, listener, true);
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
function _onceWrap(target, type, listener) {
|
|
262
|
-
var fired = false;
|
|
263
|
-
function g() {
|
|
264
|
-
target.removeListener(type, g);
|
|
265
|
-
if (!fired) {
|
|
266
|
-
fired = true;
|
|
267
|
-
listener.apply(target, arguments);
|
|
527
|
+
function setStatusClasses() {
|
|
528
|
+
if (options.addClassOn) {
|
|
529
|
+
setClasses(options.addClassOn, status);
|
|
530
|
+
}
|
|
531
|
+
if (options.addClassOff) {
|
|
532
|
+
setClasses(options.addClassOff, !status);
|
|
268
533
|
}
|
|
269
534
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
return this;
|
|
300
|
-
|
|
301
|
-
list = events[type];
|
|
302
|
-
if (!list)
|
|
303
|
-
return this;
|
|
304
|
-
|
|
305
|
-
if (list === listener || (list.listener && list.listener === listener)) {
|
|
306
|
-
if (--this._eventsCount === 0)
|
|
307
|
-
this._events = new EventHandlers();
|
|
308
|
-
else {
|
|
309
|
-
delete events[type];
|
|
310
|
-
if (events.removeListener)
|
|
311
|
-
this.emit('removeListener', type, list.listener || listener);
|
|
312
|
-
}
|
|
313
|
-
} else if (typeof list !== 'function') {
|
|
314
|
-
position = -1;
|
|
315
|
-
|
|
316
|
-
for (i = list.length; i-- > 0;) {
|
|
317
|
-
if (list[i] === listener ||
|
|
318
|
-
(list[i].listener && list[i].listener === listener)) {
|
|
319
|
-
originalListener = list[i].listener;
|
|
320
|
-
position = i;
|
|
321
|
-
break;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
if (position < 0)
|
|
326
|
-
return this;
|
|
327
|
-
|
|
328
|
-
if (list.length === 1) {
|
|
329
|
-
list[0] = undefined;
|
|
330
|
-
if (--this._eventsCount === 0) {
|
|
331
|
-
this._events = new EventHandlers();
|
|
332
|
-
return this;
|
|
333
|
-
} else {
|
|
334
|
-
delete events[type];
|
|
335
|
-
}
|
|
336
|
-
} else {
|
|
337
|
-
spliceOne(list, position);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
if (events.removeListener)
|
|
341
|
-
this.emit('removeListener', type, originalListener || listener);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
return this;
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
// Alias for removeListener added in NodeJS 10.0
|
|
348
|
-
// https://nodejs.org/api/events.html#events_emitter_off_eventname_listener
|
|
349
|
-
EventEmitter.prototype.off = function(type, listener){
|
|
350
|
-
return this.removeListener(type, listener);
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
EventEmitter.prototype.removeAllListeners =
|
|
354
|
-
function removeAllListeners(type) {
|
|
355
|
-
var listeners, events;
|
|
356
|
-
|
|
357
|
-
events = this._events;
|
|
358
|
-
if (!events)
|
|
359
|
-
return this;
|
|
360
|
-
|
|
361
|
-
// not listening for removeListener, no need to emit
|
|
362
|
-
if (!events.removeListener) {
|
|
363
|
-
if (arguments.length === 0) {
|
|
364
|
-
this._events = new EventHandlers();
|
|
365
|
-
this._eventsCount = 0;
|
|
366
|
-
} else if (events[type]) {
|
|
367
|
-
if (--this._eventsCount === 0)
|
|
368
|
-
this._events = new EventHandlers();
|
|
369
|
-
else
|
|
370
|
-
delete events[type];
|
|
371
|
-
}
|
|
372
|
-
return this;
|
|
535
|
+
setTitle();
|
|
536
|
+
setHtml();
|
|
537
|
+
if (options.addClass) {
|
|
538
|
+
setClasses(options.addClass, true);
|
|
539
|
+
}
|
|
540
|
+
setStatusClasses();
|
|
541
|
+
const changeStatus = (status_) => {
|
|
542
|
+
if (status_ !== void 0) {
|
|
543
|
+
status = status_;
|
|
544
|
+
}
|
|
545
|
+
setHtml();
|
|
546
|
+
setTitle();
|
|
547
|
+
setStatusClasses();
|
|
548
|
+
};
|
|
549
|
+
const getStatus = () => status;
|
|
550
|
+
const onClick = (status_) => {
|
|
551
|
+
if (status_ === void 0 && status && buttonControl.disableOnSecondClick) {
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
const previousStatus = status;
|
|
555
|
+
status = status_ !== void 0 ? status_ : !status;
|
|
556
|
+
if (options.onClick) {
|
|
557
|
+
let afterClick;
|
|
558
|
+
try {
|
|
559
|
+
afterClick = options.onClick(status);
|
|
560
|
+
} catch (er) {
|
|
561
|
+
status = previousStatus;
|
|
562
|
+
changeStatus();
|
|
563
|
+
throw er;
|
|
373
564
|
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
for (var i = 0, key; i < keys.length; ++i) {
|
|
379
|
-
key = keys[i];
|
|
380
|
-
if (key === 'removeListener') continue;
|
|
381
|
-
this.removeAllListeners(key);
|
|
565
|
+
Promise.resolve(afterClick).then(() => {
|
|
566
|
+
changeStatus();
|
|
567
|
+
if (previousStatus !== status) {
|
|
568
|
+
notifyStatusChange(buttonControl);
|
|
382
569
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
if (typeof listeners === 'function') {
|
|
392
|
-
this.removeListener(type, listeners);
|
|
393
|
-
} else if (listeners) {
|
|
394
|
-
// LIFO order
|
|
395
|
-
do {
|
|
396
|
-
this.removeListener(type, listeners[listeners.length - 1]);
|
|
397
|
-
} while (listeners[0]);
|
|
570
|
+
}).catch(() => {
|
|
571
|
+
status = previousStatus;
|
|
572
|
+
changeStatus();
|
|
573
|
+
});
|
|
574
|
+
} else {
|
|
575
|
+
changeStatus();
|
|
576
|
+
if (previousStatus !== status) {
|
|
577
|
+
notifyStatusChange(buttonControl);
|
|
398
578
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
evlistener = events[type];
|
|
412
|
-
if (!evlistener)
|
|
413
|
-
ret = [];
|
|
414
|
-
else if (typeof evlistener === 'function')
|
|
415
|
-
ret = [evlistener.listener || evlistener];
|
|
416
|
-
else
|
|
417
|
-
ret = unwrapListeners(evlistener);
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
return ret;
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
EventEmitter.listenerCount = function(emitter, type) {
|
|
424
|
-
if (typeof emitter.listenerCount === 'function') {
|
|
425
|
-
return emitter.listenerCount(type);
|
|
426
|
-
} else {
|
|
427
|
-
return listenerCount.call(emitter, type);
|
|
428
|
-
}
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
EventEmitter.prototype.listenerCount = listenerCount;
|
|
432
|
-
function listenerCount(type) {
|
|
433
|
-
var events = this._events;
|
|
434
|
-
|
|
435
|
-
if (events) {
|
|
436
|
-
var evlistener = events[type];
|
|
437
|
-
|
|
438
|
-
if (typeof evlistener === 'function') {
|
|
439
|
-
return 1;
|
|
440
|
-
} else if (evlistener) {
|
|
441
|
-
return evlistener.length;
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
return 0;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
EventEmitter.prototype.eventNames = function eventNames() {
|
|
449
|
-
return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
|
|
450
|
-
};
|
|
451
|
-
|
|
452
|
-
// About 1.5x faster than the two-arg version of Array#splice().
|
|
453
|
-
function spliceOne(list, index) {
|
|
454
|
-
for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
|
|
455
|
-
list[i] = list[k];
|
|
456
|
-
list.pop();
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
function arrayClone(arr, i) {
|
|
460
|
-
var copy = new Array(i);
|
|
461
|
-
while (i--)
|
|
462
|
-
copy[i] = arr[i];
|
|
463
|
-
return copy;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
function unwrapListeners(arr) {
|
|
467
|
-
var ret = new Array(arr.length);
|
|
468
|
-
for (var i = 0; i < ret.length; ++i) {
|
|
469
|
-
ret[i] = arr[i].listener || arr[i];
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
const buttonControl = createButtonControlContent({
|
|
582
|
+
html: link,
|
|
583
|
+
onClick
|
|
584
|
+
});
|
|
585
|
+
buttonControl.onClick = onClick;
|
|
586
|
+
buttonControl.changeStatus = changeStatus;
|
|
587
|
+
buttonControl.getStatus = getStatus;
|
|
588
|
+
buttonControl.switch = options.switch;
|
|
589
|
+
if (options.disableOnSecondClick !== void 0) {
|
|
590
|
+
buttonControl.disableOnSecondClick = options.disableOnSecondClick;
|
|
470
591
|
}
|
|
471
|
-
|
|
592
|
+
buttonControl.onStatusChange = (listener) => {
|
|
593
|
+
statusListeners.add(listener);
|
|
594
|
+
return () => statusListeners.delete(listener);
|
|
595
|
+
};
|
|
596
|
+
return buttonControl;
|
|
472
597
|
}
|
|
473
598
|
|
|
474
599
|
var leafletSrc$1 = {exports: {}};
|
|
@@ -13925,625 +14050,1279 @@ function requireLeafletSrc () {
|
|
|
13925
14050
|
});
|
|
13926
14051
|
|
|
13927
14052
|
// @section Handlers
|
|
13928
|
-
// @property dragging: Handler
|
|
13929
|
-
// Map dragging handler (by both mouse and touch).
|
|
13930
|
-
Map.addInitHook('addHandler', 'dragging', Drag);
|
|
14053
|
+
// @property dragging: Handler
|
|
14054
|
+
// Map dragging handler (by both mouse and touch).
|
|
14055
|
+
Map.addInitHook('addHandler', 'dragging', Drag);
|
|
14056
|
+
|
|
14057
|
+
/*
|
|
14058
|
+
* L.Map.Keyboard is handling keyboard interaction with the map, enabled by default.
|
|
14059
|
+
*/
|
|
14060
|
+
|
|
14061
|
+
// @namespace Map
|
|
14062
|
+
// @section Keyboard Navigation Options
|
|
14063
|
+
Map.mergeOptions({
|
|
14064
|
+
// @option keyboard: Boolean = true
|
|
14065
|
+
// Makes the map focusable and allows users to navigate the map with keyboard
|
|
14066
|
+
// arrows and `+`/`-` keys.
|
|
14067
|
+
keyboard: true,
|
|
14068
|
+
|
|
14069
|
+
// @option keyboardPanDelta: Number = 80
|
|
14070
|
+
// Amount of pixels to pan when pressing an arrow key.
|
|
14071
|
+
keyboardPanDelta: 80
|
|
14072
|
+
});
|
|
14073
|
+
|
|
14074
|
+
var Keyboard = Handler.extend({
|
|
14075
|
+
|
|
14076
|
+
keyCodes: {
|
|
14077
|
+
left: [37],
|
|
14078
|
+
right: [39],
|
|
14079
|
+
down: [40],
|
|
14080
|
+
up: [38],
|
|
14081
|
+
zoomIn: [187, 107, 61, 171],
|
|
14082
|
+
zoomOut: [189, 109, 54, 173]
|
|
14083
|
+
},
|
|
14084
|
+
|
|
14085
|
+
initialize: function (map) {
|
|
14086
|
+
this._map = map;
|
|
14087
|
+
|
|
14088
|
+
this._setPanDelta(map.options.keyboardPanDelta);
|
|
14089
|
+
this._setZoomDelta(map.options.zoomDelta);
|
|
14090
|
+
},
|
|
14091
|
+
|
|
14092
|
+
addHooks: function () {
|
|
14093
|
+
var container = this._map._container;
|
|
14094
|
+
|
|
14095
|
+
// make the container focusable by tabbing
|
|
14096
|
+
if (container.tabIndex <= 0) {
|
|
14097
|
+
container.tabIndex = '0';
|
|
14098
|
+
}
|
|
14099
|
+
|
|
14100
|
+
on(container, {
|
|
14101
|
+
focus: this._onFocus,
|
|
14102
|
+
blur: this._onBlur,
|
|
14103
|
+
mousedown: this._onMouseDown
|
|
14104
|
+
}, this);
|
|
14105
|
+
|
|
14106
|
+
this._map.on({
|
|
14107
|
+
focus: this._addHooks,
|
|
14108
|
+
blur: this._removeHooks
|
|
14109
|
+
}, this);
|
|
14110
|
+
},
|
|
14111
|
+
|
|
14112
|
+
removeHooks: function () {
|
|
14113
|
+
this._removeHooks();
|
|
14114
|
+
|
|
14115
|
+
off(this._map._container, {
|
|
14116
|
+
focus: this._onFocus,
|
|
14117
|
+
blur: this._onBlur,
|
|
14118
|
+
mousedown: this._onMouseDown
|
|
14119
|
+
}, this);
|
|
14120
|
+
|
|
14121
|
+
this._map.off({
|
|
14122
|
+
focus: this._addHooks,
|
|
14123
|
+
blur: this._removeHooks
|
|
14124
|
+
}, this);
|
|
14125
|
+
},
|
|
14126
|
+
|
|
14127
|
+
_onMouseDown: function () {
|
|
14128
|
+
if (this._focused) { return; }
|
|
14129
|
+
|
|
14130
|
+
var body = document.body,
|
|
14131
|
+
docEl = document.documentElement,
|
|
14132
|
+
top = body.scrollTop || docEl.scrollTop,
|
|
14133
|
+
left = body.scrollLeft || docEl.scrollLeft;
|
|
14134
|
+
|
|
14135
|
+
this._map._container.focus();
|
|
14136
|
+
|
|
14137
|
+
window.scrollTo(left, top);
|
|
14138
|
+
},
|
|
14139
|
+
|
|
14140
|
+
_onFocus: function () {
|
|
14141
|
+
this._focused = true;
|
|
14142
|
+
this._map.fire('focus');
|
|
14143
|
+
},
|
|
14144
|
+
|
|
14145
|
+
_onBlur: function () {
|
|
14146
|
+
this._focused = false;
|
|
14147
|
+
this._map.fire('blur');
|
|
14148
|
+
},
|
|
14149
|
+
|
|
14150
|
+
_setPanDelta: function (panDelta) {
|
|
14151
|
+
var keys = this._panKeys = {},
|
|
14152
|
+
codes = this.keyCodes,
|
|
14153
|
+
i, len;
|
|
14154
|
+
|
|
14155
|
+
for (i = 0, len = codes.left.length; i < len; i++) {
|
|
14156
|
+
keys[codes.left[i]] = [-1 * panDelta, 0];
|
|
14157
|
+
}
|
|
14158
|
+
for (i = 0, len = codes.right.length; i < len; i++) {
|
|
14159
|
+
keys[codes.right[i]] = [panDelta, 0];
|
|
14160
|
+
}
|
|
14161
|
+
for (i = 0, len = codes.down.length; i < len; i++) {
|
|
14162
|
+
keys[codes.down[i]] = [0, panDelta];
|
|
14163
|
+
}
|
|
14164
|
+
for (i = 0, len = codes.up.length; i < len; i++) {
|
|
14165
|
+
keys[codes.up[i]] = [0, -1 * panDelta];
|
|
14166
|
+
}
|
|
14167
|
+
},
|
|
14168
|
+
|
|
14169
|
+
_setZoomDelta: function (zoomDelta) {
|
|
14170
|
+
var keys = this._zoomKeys = {},
|
|
14171
|
+
codes = this.keyCodes,
|
|
14172
|
+
i, len;
|
|
14173
|
+
|
|
14174
|
+
for (i = 0, len = codes.zoomIn.length; i < len; i++) {
|
|
14175
|
+
keys[codes.zoomIn[i]] = zoomDelta;
|
|
14176
|
+
}
|
|
14177
|
+
for (i = 0, len = codes.zoomOut.length; i < len; i++) {
|
|
14178
|
+
keys[codes.zoomOut[i]] = -zoomDelta;
|
|
14179
|
+
}
|
|
14180
|
+
},
|
|
14181
|
+
|
|
14182
|
+
_addHooks: function () {
|
|
14183
|
+
on(document, 'keydown', this._onKeyDown, this);
|
|
14184
|
+
},
|
|
14185
|
+
|
|
14186
|
+
_removeHooks: function () {
|
|
14187
|
+
off(document, 'keydown', this._onKeyDown, this);
|
|
14188
|
+
},
|
|
14189
|
+
|
|
14190
|
+
_onKeyDown: function (e) {
|
|
14191
|
+
if (e.altKey || e.ctrlKey || e.metaKey) { return; }
|
|
14192
|
+
|
|
14193
|
+
var key = e.keyCode,
|
|
14194
|
+
map = this._map,
|
|
14195
|
+
offset;
|
|
14196
|
+
|
|
14197
|
+
if (key in this._panKeys) {
|
|
14198
|
+
if (!map._panAnim || !map._panAnim._inProgress) {
|
|
14199
|
+
offset = this._panKeys[key];
|
|
14200
|
+
if (e.shiftKey) {
|
|
14201
|
+
offset = toPoint(offset).multiplyBy(3);
|
|
14202
|
+
}
|
|
14203
|
+
|
|
14204
|
+
map.panBy(offset);
|
|
14205
|
+
|
|
14206
|
+
if (map.options.maxBounds) {
|
|
14207
|
+
map.panInsideBounds(map.options.maxBounds);
|
|
14208
|
+
}
|
|
14209
|
+
}
|
|
14210
|
+
} else if (key in this._zoomKeys) {
|
|
14211
|
+
map.setZoom(map.getZoom() + (e.shiftKey ? 3 : 1) * this._zoomKeys[key]);
|
|
14212
|
+
|
|
14213
|
+
} else if (key === 27 && map._popup && map._popup.options.closeOnEscapeKey) {
|
|
14214
|
+
map.closePopup();
|
|
14215
|
+
|
|
14216
|
+
} else {
|
|
14217
|
+
return;
|
|
14218
|
+
}
|
|
14219
|
+
|
|
14220
|
+
stop(e);
|
|
14221
|
+
}
|
|
14222
|
+
});
|
|
14223
|
+
|
|
14224
|
+
// @section Handlers
|
|
14225
|
+
// @section Handlers
|
|
14226
|
+
// @property keyboard: Handler
|
|
14227
|
+
// Keyboard navigation handler.
|
|
14228
|
+
Map.addInitHook('addHandler', 'keyboard', Keyboard);
|
|
14229
|
+
|
|
14230
|
+
/*
|
|
14231
|
+
* L.Handler.ScrollWheelZoom is used by L.Map to enable mouse scroll wheel zoom on the map.
|
|
14232
|
+
*/
|
|
14233
|
+
|
|
14234
|
+
// @namespace Map
|
|
14235
|
+
// @section Interaction Options
|
|
14236
|
+
Map.mergeOptions({
|
|
14237
|
+
// @section Mouse wheel options
|
|
14238
|
+
// @option scrollWheelZoom: Boolean|String = true
|
|
14239
|
+
// Whether the map can be zoomed by using the mouse wheel. If passed `'center'`,
|
|
14240
|
+
// it will zoom to the center of the view regardless of where the mouse was.
|
|
14241
|
+
scrollWheelZoom: true,
|
|
14242
|
+
|
|
14243
|
+
// @option wheelDebounceTime: Number = 40
|
|
14244
|
+
// Limits the rate at which a wheel can fire (in milliseconds). By default
|
|
14245
|
+
// user can't zoom via wheel more often than once per 40 ms.
|
|
14246
|
+
wheelDebounceTime: 40,
|
|
14247
|
+
|
|
14248
|
+
// @option wheelPxPerZoomLevel: Number = 60
|
|
14249
|
+
// How many scroll pixels (as reported by [L.DomEvent.getWheelDelta](#domevent-getwheeldelta))
|
|
14250
|
+
// mean a change of one full zoom level. Smaller values will make wheel-zooming
|
|
14251
|
+
// faster (and vice versa).
|
|
14252
|
+
wheelPxPerZoomLevel: 60
|
|
14253
|
+
});
|
|
14254
|
+
|
|
14255
|
+
var ScrollWheelZoom = Handler.extend({
|
|
14256
|
+
addHooks: function () {
|
|
14257
|
+
on(this._map._container, 'wheel', this._onWheelScroll, this);
|
|
14258
|
+
|
|
14259
|
+
this._delta = 0;
|
|
14260
|
+
},
|
|
14261
|
+
|
|
14262
|
+
removeHooks: function () {
|
|
14263
|
+
off(this._map._container, 'wheel', this._onWheelScroll, this);
|
|
14264
|
+
},
|
|
14265
|
+
|
|
14266
|
+
_onWheelScroll: function (e) {
|
|
14267
|
+
var delta = getWheelDelta(e);
|
|
14268
|
+
|
|
14269
|
+
var debounce = this._map.options.wheelDebounceTime;
|
|
14270
|
+
|
|
14271
|
+
this._delta += delta;
|
|
14272
|
+
this._lastMousePos = this._map.mouseEventToContainerPoint(e);
|
|
14273
|
+
|
|
14274
|
+
if (!this._startTime) {
|
|
14275
|
+
this._startTime = +new Date();
|
|
14276
|
+
}
|
|
14277
|
+
|
|
14278
|
+
var left = Math.max(debounce - (+new Date() - this._startTime), 0);
|
|
14279
|
+
|
|
14280
|
+
clearTimeout(this._timer);
|
|
14281
|
+
this._timer = setTimeout(bind(this._performZoom, this), left);
|
|
14282
|
+
|
|
14283
|
+
stop(e);
|
|
14284
|
+
},
|
|
14285
|
+
|
|
14286
|
+
_performZoom: function () {
|
|
14287
|
+
var map = this._map,
|
|
14288
|
+
zoom = map.getZoom(),
|
|
14289
|
+
snap = this._map.options.zoomSnap || 0;
|
|
14290
|
+
|
|
14291
|
+
map._stop(); // stop panning and fly animations if any
|
|
14292
|
+
|
|
14293
|
+
// map the delta with a sigmoid function to -4..4 range leaning on -1..1
|
|
14294
|
+
var d2 = this._delta / (this._map.options.wheelPxPerZoomLevel * 4),
|
|
14295
|
+
d3 = 4 * Math.log(2 / (1 + Math.exp(-Math.abs(d2)))) / Math.LN2,
|
|
14296
|
+
d4 = snap ? Math.ceil(d3 / snap) * snap : d3,
|
|
14297
|
+
delta = map._limitZoom(zoom + (this._delta > 0 ? d4 : -d4)) - zoom;
|
|
14298
|
+
|
|
14299
|
+
this._delta = 0;
|
|
14300
|
+
this._startTime = null;
|
|
14301
|
+
|
|
14302
|
+
if (!delta) { return; }
|
|
14303
|
+
|
|
14304
|
+
if (map.options.scrollWheelZoom === 'center') {
|
|
14305
|
+
map.setZoom(zoom + delta);
|
|
14306
|
+
} else {
|
|
14307
|
+
map.setZoomAround(this._lastMousePos, zoom + delta);
|
|
14308
|
+
}
|
|
14309
|
+
}
|
|
14310
|
+
});
|
|
14311
|
+
|
|
14312
|
+
// @section Handlers
|
|
14313
|
+
// @property scrollWheelZoom: Handler
|
|
14314
|
+
// Scroll wheel zoom handler.
|
|
14315
|
+
Map.addInitHook('addHandler', 'scrollWheelZoom', ScrollWheelZoom);
|
|
13931
14316
|
|
|
13932
14317
|
/*
|
|
13933
|
-
* L.Map.
|
|
14318
|
+
* L.Map.Tap is used to enable mobile hacks like quick taps and long hold.
|
|
13934
14319
|
*/
|
|
13935
14320
|
|
|
13936
14321
|
// @namespace Map
|
|
13937
|
-
// @section
|
|
14322
|
+
// @section Interaction Options
|
|
13938
14323
|
Map.mergeOptions({
|
|
13939
|
-
// @
|
|
13940
|
-
//
|
|
13941
|
-
//
|
|
13942
|
-
|
|
14324
|
+
// @section Touch interaction options
|
|
14325
|
+
// @option tap: Boolean = true
|
|
14326
|
+
// Enables mobile hacks for supporting instant taps (fixing 200ms click
|
|
14327
|
+
// delay on iOS/Android) and touch holds (fired as `contextmenu` events).
|
|
14328
|
+
tap: true,
|
|
13943
14329
|
|
|
13944
|
-
// @option
|
|
13945
|
-
//
|
|
13946
|
-
|
|
14330
|
+
// @option tapTolerance: Number = 15
|
|
14331
|
+
// The max number of pixels a user can shift his finger during touch
|
|
14332
|
+
// for it to be considered a valid tap.
|
|
14333
|
+
tapTolerance: 15
|
|
13947
14334
|
});
|
|
13948
14335
|
|
|
13949
|
-
var
|
|
14336
|
+
var Tap = Handler.extend({
|
|
14337
|
+
addHooks: function () {
|
|
14338
|
+
on(this._map._container, 'touchstart', this._onDown, this);
|
|
14339
|
+
},
|
|
13950
14340
|
|
|
13951
|
-
|
|
13952
|
-
|
|
13953
|
-
right: [39],
|
|
13954
|
-
down: [40],
|
|
13955
|
-
up: [38],
|
|
13956
|
-
zoomIn: [187, 107, 61, 171],
|
|
13957
|
-
zoomOut: [189, 109, 54, 173]
|
|
14341
|
+
removeHooks: function () {
|
|
14342
|
+
off(this._map._container, 'touchstart', this._onDown, this);
|
|
13958
14343
|
},
|
|
13959
14344
|
|
|
13960
|
-
|
|
13961
|
-
|
|
14345
|
+
_onDown: function (e) {
|
|
14346
|
+
if (!e.touches) { return; }
|
|
13962
14347
|
|
|
13963
|
-
|
|
13964
|
-
this._setZoomDelta(map.options.zoomDelta);
|
|
13965
|
-
},
|
|
14348
|
+
preventDefault(e);
|
|
13966
14349
|
|
|
13967
|
-
|
|
13968
|
-
var container = this._map._container;
|
|
14350
|
+
this._fireClick = true;
|
|
13969
14351
|
|
|
13970
|
-
//
|
|
13971
|
-
if (
|
|
13972
|
-
|
|
14352
|
+
// don't simulate click or track longpress if more than 1 touch
|
|
14353
|
+
if (e.touches.length > 1) {
|
|
14354
|
+
this._fireClick = false;
|
|
14355
|
+
clearTimeout(this._holdTimeout);
|
|
14356
|
+
return;
|
|
13973
14357
|
}
|
|
13974
14358
|
|
|
13975
|
-
|
|
13976
|
-
|
|
13977
|
-
blur: this._onBlur,
|
|
13978
|
-
mousedown: this._onMouseDown
|
|
13979
|
-
}, this);
|
|
14359
|
+
var first = e.touches[0],
|
|
14360
|
+
el = first.target;
|
|
13980
14361
|
|
|
13981
|
-
this.
|
|
13982
|
-
|
|
13983
|
-
|
|
14362
|
+
this._startPos = this._newPos = new Point(first.clientX, first.clientY);
|
|
14363
|
+
|
|
14364
|
+
// if touching a link, highlight it
|
|
14365
|
+
if (el.tagName && el.tagName.toLowerCase() === 'a') {
|
|
14366
|
+
addClass(el, 'leaflet-active');
|
|
14367
|
+
}
|
|
14368
|
+
|
|
14369
|
+
// simulate long hold but setting a timeout
|
|
14370
|
+
this._holdTimeout = setTimeout(bind(function () {
|
|
14371
|
+
if (this._isTapValid()) {
|
|
14372
|
+
this._fireClick = false;
|
|
14373
|
+
this._onUp();
|
|
14374
|
+
this._simulateEvent('contextmenu', first);
|
|
14375
|
+
}
|
|
14376
|
+
}, this), 1000);
|
|
14377
|
+
|
|
14378
|
+
this._simulateEvent('mousedown', first);
|
|
14379
|
+
|
|
14380
|
+
on(document, {
|
|
14381
|
+
touchmove: this._onMove,
|
|
14382
|
+
touchend: this._onUp
|
|
13984
14383
|
}, this);
|
|
13985
14384
|
},
|
|
13986
14385
|
|
|
13987
|
-
|
|
13988
|
-
this.
|
|
14386
|
+
_onUp: function (e) {
|
|
14387
|
+
clearTimeout(this._holdTimeout);
|
|
13989
14388
|
|
|
13990
|
-
off(
|
|
13991
|
-
|
|
13992
|
-
|
|
13993
|
-
mousedown: this._onMouseDown
|
|
14389
|
+
off(document, {
|
|
14390
|
+
touchmove: this._onMove,
|
|
14391
|
+
touchend: this._onUp
|
|
13994
14392
|
}, this);
|
|
13995
14393
|
|
|
13996
|
-
this.
|
|
13997
|
-
focus: this._addHooks,
|
|
13998
|
-
blur: this._removeHooks
|
|
13999
|
-
}, this);
|
|
14000
|
-
},
|
|
14394
|
+
if (this._fireClick && e && e.changedTouches) {
|
|
14001
14395
|
|
|
14002
|
-
|
|
14003
|
-
|
|
14396
|
+
var first = e.changedTouches[0],
|
|
14397
|
+
el = first.target;
|
|
14004
14398
|
|
|
14005
|
-
|
|
14006
|
-
|
|
14007
|
-
|
|
14008
|
-
left = body.scrollLeft || docEl.scrollLeft;
|
|
14399
|
+
if (el && el.tagName && el.tagName.toLowerCase() === 'a') {
|
|
14400
|
+
removeClass(el, 'leaflet-active');
|
|
14401
|
+
}
|
|
14009
14402
|
|
|
14010
|
-
|
|
14403
|
+
this._simulateEvent('mouseup', first);
|
|
14011
14404
|
|
|
14012
|
-
|
|
14405
|
+
// simulate click if the touch didn't move too much
|
|
14406
|
+
if (this._isTapValid()) {
|
|
14407
|
+
this._simulateEvent('click', first);
|
|
14408
|
+
}
|
|
14409
|
+
}
|
|
14013
14410
|
},
|
|
14014
14411
|
|
|
14015
|
-
|
|
14016
|
-
this.
|
|
14017
|
-
this._map.fire('focus');
|
|
14412
|
+
_isTapValid: function () {
|
|
14413
|
+
return this._newPos.distanceTo(this._startPos) <= this._map.options.tapTolerance;
|
|
14018
14414
|
},
|
|
14019
14415
|
|
|
14020
|
-
|
|
14021
|
-
|
|
14022
|
-
this.
|
|
14416
|
+
_onMove: function (e) {
|
|
14417
|
+
var first = e.touches[0];
|
|
14418
|
+
this._newPos = new Point(first.clientX, first.clientY);
|
|
14419
|
+
this._simulateEvent('mousemove', first);
|
|
14023
14420
|
},
|
|
14024
14421
|
|
|
14025
|
-
|
|
14026
|
-
var
|
|
14027
|
-
codes = this.keyCodes,
|
|
14028
|
-
i, len;
|
|
14422
|
+
_simulateEvent: function (type, e) {
|
|
14423
|
+
var simulatedEvent = document.createEvent('MouseEvents');
|
|
14029
14424
|
|
|
14030
|
-
|
|
14031
|
-
|
|
14032
|
-
}
|
|
14033
|
-
for (i = 0, len = codes.right.length; i < len; i++) {
|
|
14034
|
-
keys[codes.right[i]] = [panDelta, 0];
|
|
14035
|
-
}
|
|
14036
|
-
for (i = 0, len = codes.down.length; i < len; i++) {
|
|
14037
|
-
keys[codes.down[i]] = [0, panDelta];
|
|
14038
|
-
}
|
|
14039
|
-
for (i = 0, len = codes.up.length; i < len; i++) {
|
|
14040
|
-
keys[codes.up[i]] = [0, -1 * panDelta];
|
|
14041
|
-
}
|
|
14042
|
-
},
|
|
14425
|
+
simulatedEvent._simulated = true;
|
|
14426
|
+
e.target._simulatedClick = true;
|
|
14043
14427
|
|
|
14044
|
-
|
|
14045
|
-
|
|
14046
|
-
|
|
14047
|
-
|
|
14428
|
+
simulatedEvent.initMouseEvent(
|
|
14429
|
+
type, true, true, window, 1,
|
|
14430
|
+
e.screenX, e.screenY,
|
|
14431
|
+
e.clientX, e.clientY,
|
|
14432
|
+
false, false, false, false, 0, null);
|
|
14048
14433
|
|
|
14049
|
-
|
|
14050
|
-
|
|
14051
|
-
|
|
14052
|
-
for (i = 0, len = codes.zoomOut.length; i < len; i++) {
|
|
14053
|
-
keys[codes.zoomOut[i]] = -zoomDelta;
|
|
14054
|
-
}
|
|
14055
|
-
},
|
|
14434
|
+
e.target.dispatchEvent(simulatedEvent);
|
|
14435
|
+
}
|
|
14436
|
+
});
|
|
14056
14437
|
|
|
14057
|
-
|
|
14058
|
-
|
|
14059
|
-
|
|
14438
|
+
// @section Handlers
|
|
14439
|
+
// @property tap: Handler
|
|
14440
|
+
// Mobile touch hacks (quick tap and touch hold) handler.
|
|
14441
|
+
if (touch && (!pointer || safari)) {
|
|
14442
|
+
Map.addInitHook('addHandler', 'tap', Tap);
|
|
14443
|
+
}
|
|
14060
14444
|
|
|
14061
|
-
|
|
14062
|
-
|
|
14445
|
+
/*
|
|
14446
|
+
* L.Handler.TouchZoom is used by L.Map to add pinch zoom on supported mobile browsers.
|
|
14447
|
+
*/
|
|
14448
|
+
|
|
14449
|
+
// @namespace Map
|
|
14450
|
+
// @section Interaction Options
|
|
14451
|
+
Map.mergeOptions({
|
|
14452
|
+
// @section Touch interaction options
|
|
14453
|
+
// @option touchZoom: Boolean|String = *
|
|
14454
|
+
// Whether the map can be zoomed by touch-dragging with two fingers. If
|
|
14455
|
+
// passed `'center'`, it will zoom to the center of the view regardless of
|
|
14456
|
+
// where the touch events (fingers) were. Enabled for touch-capable web
|
|
14457
|
+
// browsers except for old Androids.
|
|
14458
|
+
touchZoom: touch && !android23,
|
|
14459
|
+
|
|
14460
|
+
// @option bounceAtZoomLimits: Boolean = true
|
|
14461
|
+
// Set it to false if you don't want the map to zoom beyond min/max zoom
|
|
14462
|
+
// and then bounce back when pinch-zooming.
|
|
14463
|
+
bounceAtZoomLimits: true
|
|
14464
|
+
});
|
|
14465
|
+
|
|
14466
|
+
var TouchZoom = Handler.extend({
|
|
14467
|
+
addHooks: function () {
|
|
14468
|
+
addClass(this._map._container, 'leaflet-touch-zoom');
|
|
14469
|
+
on(this._map._container, 'touchstart', this._onTouchStart, this);
|
|
14063
14470
|
},
|
|
14064
14471
|
|
|
14065
|
-
|
|
14066
|
-
|
|
14472
|
+
removeHooks: function () {
|
|
14473
|
+
removeClass(this._map._container, 'leaflet-touch-zoom');
|
|
14474
|
+
off(this._map._container, 'touchstart', this._onTouchStart, this);
|
|
14475
|
+
},
|
|
14067
14476
|
|
|
14068
|
-
|
|
14069
|
-
|
|
14070
|
-
|
|
14477
|
+
_onTouchStart: function (e) {
|
|
14478
|
+
var map = this._map;
|
|
14479
|
+
if (!e.touches || e.touches.length !== 2 || map._animatingZoom || this._zooming) { return; }
|
|
14071
14480
|
|
|
14072
|
-
|
|
14073
|
-
|
|
14074
|
-
offset = this._panKeys[key];
|
|
14075
|
-
if (e.shiftKey) {
|
|
14076
|
-
offset = toPoint(offset).multiplyBy(3);
|
|
14077
|
-
}
|
|
14481
|
+
var p1 = map.mouseEventToContainerPoint(e.touches[0]),
|
|
14482
|
+
p2 = map.mouseEventToContainerPoint(e.touches[1]);
|
|
14078
14483
|
|
|
14079
|
-
|
|
14484
|
+
this._centerPoint = map.getSize()._divideBy(2);
|
|
14485
|
+
this._startLatLng = map.containerPointToLatLng(this._centerPoint);
|
|
14486
|
+
if (map.options.touchZoom !== 'center') {
|
|
14487
|
+
this._pinchStartLatLng = map.containerPointToLatLng(p1.add(p2)._divideBy(2));
|
|
14488
|
+
}
|
|
14080
14489
|
|
|
14081
|
-
|
|
14082
|
-
|
|
14083
|
-
}
|
|
14084
|
-
}
|
|
14085
|
-
} else if (key in this._zoomKeys) {
|
|
14086
|
-
map.setZoom(map.getZoom() + (e.shiftKey ? 3 : 1) * this._zoomKeys[key]);
|
|
14490
|
+
this._startDist = p1.distanceTo(p2);
|
|
14491
|
+
this._startZoom = map.getZoom();
|
|
14087
14492
|
|
|
14088
|
-
|
|
14089
|
-
|
|
14493
|
+
this._moved = false;
|
|
14494
|
+
this._zooming = true;
|
|
14090
14495
|
|
|
14091
|
-
|
|
14092
|
-
return;
|
|
14093
|
-
}
|
|
14496
|
+
map._stop();
|
|
14094
14497
|
|
|
14095
|
-
|
|
14096
|
-
|
|
14097
|
-
});
|
|
14498
|
+
on(document, 'touchmove', this._onTouchMove, this);
|
|
14499
|
+
on(document, 'touchend', this._onTouchEnd, this);
|
|
14098
14500
|
|
|
14099
|
-
|
|
14100
|
-
|
|
14101
|
-
// @property keyboard: Handler
|
|
14102
|
-
// Keyboard navigation handler.
|
|
14103
|
-
Map.addInitHook('addHandler', 'keyboard', Keyboard);
|
|
14501
|
+
preventDefault(e);
|
|
14502
|
+
},
|
|
14104
14503
|
|
|
14105
|
-
|
|
14106
|
-
|
|
14107
|
-
*/
|
|
14504
|
+
_onTouchMove: function (e) {
|
|
14505
|
+
if (!e.touches || e.touches.length !== 2 || !this._zooming) { return; }
|
|
14108
14506
|
|
|
14109
|
-
|
|
14110
|
-
|
|
14111
|
-
|
|
14112
|
-
|
|
14113
|
-
// @option scrollWheelZoom: Boolean|String = true
|
|
14114
|
-
// Whether the map can be zoomed by using the mouse wheel. If passed `'center'`,
|
|
14115
|
-
// it will zoom to the center of the view regardless of where the mouse was.
|
|
14116
|
-
scrollWheelZoom: true,
|
|
14507
|
+
var map = this._map,
|
|
14508
|
+
p1 = map.mouseEventToContainerPoint(e.touches[0]),
|
|
14509
|
+
p2 = map.mouseEventToContainerPoint(e.touches[1]),
|
|
14510
|
+
scale = p1.distanceTo(p2) / this._startDist;
|
|
14117
14511
|
|
|
14118
|
-
|
|
14119
|
-
// Limits the rate at which a wheel can fire (in milliseconds). By default
|
|
14120
|
-
// user can't zoom via wheel more often than once per 40 ms.
|
|
14121
|
-
wheelDebounceTime: 40,
|
|
14512
|
+
this._zoom = map.getScaleZoom(scale, this._startZoom);
|
|
14122
14513
|
|
|
14123
|
-
|
|
14124
|
-
|
|
14125
|
-
|
|
14126
|
-
|
|
14127
|
-
|
|
14128
|
-
});
|
|
14514
|
+
if (!map.options.bounceAtZoomLimits && (
|
|
14515
|
+
(this._zoom < map.getMinZoom() && scale < 1) ||
|
|
14516
|
+
(this._zoom > map.getMaxZoom() && scale > 1))) {
|
|
14517
|
+
this._zoom = map._limitZoom(this._zoom);
|
|
14518
|
+
}
|
|
14129
14519
|
|
|
14130
|
-
|
|
14131
|
-
|
|
14132
|
-
|
|
14520
|
+
if (map.options.touchZoom === 'center') {
|
|
14521
|
+
this._center = this._startLatLng;
|
|
14522
|
+
if (scale === 1) { return; }
|
|
14523
|
+
} else {
|
|
14524
|
+
// Get delta from pinch to center, so centerLatLng is delta applied to initial pinchLatLng
|
|
14525
|
+
var delta = p1._add(p2)._divideBy(2)._subtract(this._centerPoint);
|
|
14526
|
+
if (scale === 1 && delta.x === 0 && delta.y === 0) { return; }
|
|
14527
|
+
this._center = map.unproject(map.project(this._pinchStartLatLng, this._zoom).subtract(delta), this._zoom);
|
|
14528
|
+
}
|
|
14133
14529
|
|
|
14134
|
-
this.
|
|
14135
|
-
|
|
14530
|
+
if (!this._moved) {
|
|
14531
|
+
map._moveStart(true, false);
|
|
14532
|
+
this._moved = true;
|
|
14533
|
+
}
|
|
14136
14534
|
|
|
14137
|
-
|
|
14138
|
-
|
|
14535
|
+
cancelAnimFrame(this._animRequest);
|
|
14536
|
+
|
|
14537
|
+
var moveFn = bind(map._move, map, this._center, this._zoom, {pinch: true, round: false});
|
|
14538
|
+
this._animRequest = requestAnimFrame(moveFn, this, true);
|
|
14539
|
+
|
|
14540
|
+
preventDefault(e);
|
|
14139
14541
|
},
|
|
14140
14542
|
|
|
14141
|
-
|
|
14142
|
-
|
|
14543
|
+
_onTouchEnd: function () {
|
|
14544
|
+
if (!this._moved || !this._zooming) {
|
|
14545
|
+
this._zooming = false;
|
|
14546
|
+
return;
|
|
14547
|
+
}
|
|
14143
14548
|
|
|
14144
|
-
|
|
14549
|
+
this._zooming = false;
|
|
14550
|
+
cancelAnimFrame(this._animRequest);
|
|
14145
14551
|
|
|
14146
|
-
this.
|
|
14147
|
-
this.
|
|
14552
|
+
off(document, 'touchmove', this._onTouchMove, this);
|
|
14553
|
+
off(document, 'touchend', this._onTouchEnd, this);
|
|
14148
14554
|
|
|
14149
|
-
|
|
14150
|
-
|
|
14555
|
+
// Pinch updates GridLayers' levels only when zoomSnap is off, so zoomSnap becomes noUpdate.
|
|
14556
|
+
if (this._map.options.zoomAnimation) {
|
|
14557
|
+
this._map._animateZoom(this._center, this._map._limitZoom(this._zoom), true, this._map.options.zoomSnap);
|
|
14558
|
+
} else {
|
|
14559
|
+
this._map._resetView(this._center, this._map._limitZoom(this._zoom));
|
|
14151
14560
|
}
|
|
14561
|
+
}
|
|
14562
|
+
});
|
|
14152
14563
|
|
|
14153
|
-
|
|
14564
|
+
// @section Handlers
|
|
14565
|
+
// @property touchZoom: Handler
|
|
14566
|
+
// Touch zoom handler.
|
|
14567
|
+
Map.addInitHook('addHandler', 'touchZoom', TouchZoom);
|
|
14154
14568
|
|
|
14155
|
-
|
|
14156
|
-
|
|
14569
|
+
Map.BoxZoom = BoxZoom;
|
|
14570
|
+
Map.DoubleClickZoom = DoubleClickZoom;
|
|
14571
|
+
Map.Drag = Drag;
|
|
14572
|
+
Map.Keyboard = Keyboard;
|
|
14573
|
+
Map.ScrollWheelZoom = ScrollWheelZoom;
|
|
14574
|
+
Map.Tap = Tap;
|
|
14575
|
+
Map.TouchZoom = TouchZoom;
|
|
14157
14576
|
|
|
14158
|
-
|
|
14159
|
-
|
|
14577
|
+
exports.version = version;
|
|
14578
|
+
exports.Control = Control;
|
|
14579
|
+
exports.control = control;
|
|
14580
|
+
exports.Browser = Browser;
|
|
14581
|
+
exports.Evented = Evented;
|
|
14582
|
+
exports.Mixin = Mixin;
|
|
14583
|
+
exports.Util = Util;
|
|
14584
|
+
exports.Class = Class;
|
|
14585
|
+
exports.Handler = Handler;
|
|
14586
|
+
exports.extend = extend;
|
|
14587
|
+
exports.bind = bind;
|
|
14588
|
+
exports.stamp = stamp;
|
|
14589
|
+
exports.setOptions = setOptions;
|
|
14590
|
+
exports.DomEvent = DomEvent;
|
|
14591
|
+
exports.DomUtil = DomUtil;
|
|
14592
|
+
exports.PosAnimation = PosAnimation;
|
|
14593
|
+
exports.Draggable = Draggable;
|
|
14594
|
+
exports.LineUtil = LineUtil;
|
|
14595
|
+
exports.PolyUtil = PolyUtil;
|
|
14596
|
+
exports.Point = Point;
|
|
14597
|
+
exports.point = toPoint;
|
|
14598
|
+
exports.Bounds = Bounds;
|
|
14599
|
+
exports.bounds = toBounds;
|
|
14600
|
+
exports.Transformation = Transformation;
|
|
14601
|
+
exports.transformation = toTransformation;
|
|
14602
|
+
exports.Projection = index;
|
|
14603
|
+
exports.LatLng = LatLng;
|
|
14604
|
+
exports.latLng = toLatLng;
|
|
14605
|
+
exports.LatLngBounds = LatLngBounds;
|
|
14606
|
+
exports.latLngBounds = toLatLngBounds;
|
|
14607
|
+
exports.CRS = CRS;
|
|
14608
|
+
exports.GeoJSON = GeoJSON;
|
|
14609
|
+
exports.geoJSON = geoJSON;
|
|
14610
|
+
exports.geoJson = geoJson;
|
|
14611
|
+
exports.Layer = Layer;
|
|
14612
|
+
exports.LayerGroup = LayerGroup;
|
|
14613
|
+
exports.layerGroup = layerGroup;
|
|
14614
|
+
exports.FeatureGroup = FeatureGroup;
|
|
14615
|
+
exports.featureGroup = featureGroup;
|
|
14616
|
+
exports.ImageOverlay = ImageOverlay;
|
|
14617
|
+
exports.imageOverlay = imageOverlay;
|
|
14618
|
+
exports.VideoOverlay = VideoOverlay;
|
|
14619
|
+
exports.videoOverlay = videoOverlay;
|
|
14620
|
+
exports.SVGOverlay = SVGOverlay;
|
|
14621
|
+
exports.svgOverlay = svgOverlay;
|
|
14622
|
+
exports.DivOverlay = DivOverlay;
|
|
14623
|
+
exports.Popup = Popup;
|
|
14624
|
+
exports.popup = popup;
|
|
14625
|
+
exports.Tooltip = Tooltip;
|
|
14626
|
+
exports.tooltip = tooltip;
|
|
14627
|
+
exports.Icon = Icon;
|
|
14628
|
+
exports.icon = icon;
|
|
14629
|
+
exports.DivIcon = DivIcon;
|
|
14630
|
+
exports.divIcon = divIcon;
|
|
14631
|
+
exports.Marker = Marker;
|
|
14632
|
+
exports.marker = marker;
|
|
14633
|
+
exports.TileLayer = TileLayer;
|
|
14634
|
+
exports.tileLayer = tileLayer;
|
|
14635
|
+
exports.GridLayer = GridLayer;
|
|
14636
|
+
exports.gridLayer = gridLayer;
|
|
14637
|
+
exports.SVG = SVG;
|
|
14638
|
+
exports.svg = svg$1;
|
|
14639
|
+
exports.Renderer = Renderer;
|
|
14640
|
+
exports.Canvas = Canvas;
|
|
14641
|
+
exports.canvas = canvas$1;
|
|
14642
|
+
exports.Path = Path;
|
|
14643
|
+
exports.CircleMarker = CircleMarker;
|
|
14644
|
+
exports.circleMarker = circleMarker;
|
|
14645
|
+
exports.Circle = Circle;
|
|
14646
|
+
exports.circle = circle;
|
|
14647
|
+
exports.Polyline = Polyline;
|
|
14648
|
+
exports.polyline = polyline;
|
|
14649
|
+
exports.Polygon = Polygon;
|
|
14650
|
+
exports.polygon = polygon;
|
|
14651
|
+
exports.Rectangle = Rectangle;
|
|
14652
|
+
exports.rectangle = rectangle;
|
|
14653
|
+
exports.Map = Map;
|
|
14654
|
+
exports.map = createMap;
|
|
14160
14655
|
|
|
14161
|
-
|
|
14162
|
-
|
|
14163
|
-
|
|
14164
|
-
|
|
14656
|
+
var oldL = window.L;
|
|
14657
|
+
exports.noConflict = function() {
|
|
14658
|
+
window.L = oldL;
|
|
14659
|
+
return this;
|
|
14660
|
+
};
|
|
14165
14661
|
|
|
14166
|
-
|
|
14662
|
+
// Always export us to window global (see #2364)
|
|
14663
|
+
window.L = exports;
|
|
14167
14664
|
|
|
14168
|
-
|
|
14169
|
-
|
|
14170
|
-
|
|
14171
|
-
|
|
14172
|
-
|
|
14665
|
+
})));
|
|
14666
|
+
|
|
14667
|
+
} (leafletSrc$1, leafletSrc$1.exports));
|
|
14668
|
+
return leafletSrc$1.exports;
|
|
14669
|
+
}
|
|
14173
14670
|
|
|
14174
|
-
|
|
14175
|
-
this._startTime = null;
|
|
14671
|
+
var leafletSrcExports = /*@__PURE__*/ requireLeafletSrc();
|
|
14176
14672
|
|
|
14177
|
-
|
|
14673
|
+
var __defProp$e = Object.defineProperty;
|
|
14674
|
+
var __defProps$7 = Object.defineProperties;
|
|
14675
|
+
var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
|
|
14676
|
+
var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
|
|
14677
|
+
var __hasOwnProp$a = Object.prototype.hasOwnProperty;
|
|
14678
|
+
var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
|
|
14679
|
+
var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
14680
|
+
var __spreadValues$a = (a, b) => {
|
|
14681
|
+
for (var prop in b || (b = {}))
|
|
14682
|
+
if (__hasOwnProp$a.call(b, prop))
|
|
14683
|
+
__defNormalProp$e(a, prop, b[prop]);
|
|
14684
|
+
if (__getOwnPropSymbols$a)
|
|
14685
|
+
for (var prop of __getOwnPropSymbols$a(b)) {
|
|
14686
|
+
if (__propIsEnum$a.call(b, prop))
|
|
14687
|
+
__defNormalProp$e(a, prop, b[prop]);
|
|
14688
|
+
}
|
|
14689
|
+
return a;
|
|
14690
|
+
};
|
|
14691
|
+
var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
|
|
14692
|
+
function createControl(control, options = {}, map) {
|
|
14693
|
+
const resolvedOptions = resolveControlOptions(options);
|
|
14694
|
+
const C = leafletSrcExports.Control.extend({
|
|
14695
|
+
onAdd(leafletMap) {
|
|
14696
|
+
const addClass = [
|
|
14697
|
+
"leaflet-control",
|
|
14698
|
+
resolvedOptions.bar ? "leaflet-bar" : "",
|
|
14699
|
+
resolvedOptions.addClass
|
|
14700
|
+
].filter(Boolean).join(" ");
|
|
14701
|
+
const element = createControlElement(
|
|
14702
|
+
control,
|
|
14703
|
+
__spreadProps$7(__spreadValues$a({}, resolvedOptions), { addClass }),
|
|
14704
|
+
map != null ? map : leafletMap
|
|
14705
|
+
);
|
|
14706
|
+
if (!resolvedOptions.margin) {
|
|
14707
|
+
element.style.margin = "0px";
|
|
14708
|
+
}
|
|
14709
|
+
return element;
|
|
14710
|
+
},
|
|
14711
|
+
onRemove(leafletMap) {
|
|
14712
|
+
control.onRemove(map != null ? map : leafletMap);
|
|
14713
|
+
}
|
|
14714
|
+
});
|
|
14715
|
+
const instance = new C();
|
|
14716
|
+
setControlOptions(instance, resolvedOptions);
|
|
14717
|
+
return instance;
|
|
14718
|
+
}
|
|
14719
|
+
|
|
14720
|
+
function createButtonControl(options, map) {
|
|
14721
|
+
return createControl(
|
|
14722
|
+
createButtonControlContent(options),
|
|
14723
|
+
{ bar: true, margin: options.margin },
|
|
14724
|
+
map
|
|
14725
|
+
);
|
|
14726
|
+
}
|
|
14727
|
+
|
|
14728
|
+
function createToggleControl(options, map) {
|
|
14729
|
+
const toggleContent = createToggleControlContent(options);
|
|
14730
|
+
const control = createControl(
|
|
14731
|
+
toggleContent,
|
|
14732
|
+
{ bar: true, margin: options.margin },
|
|
14733
|
+
map
|
|
14734
|
+
);
|
|
14735
|
+
control.onClick = toggleContent.onClick;
|
|
14736
|
+
control.changeStatus = toggleContent.changeStatus;
|
|
14737
|
+
control.getStatus = toggleContent.getStatus;
|
|
14738
|
+
control.switch = toggleContent.switch;
|
|
14739
|
+
Object.defineProperty(control, "disableOnSecondClick", {
|
|
14740
|
+
configurable: true,
|
|
14741
|
+
get: () => toggleContent.disableOnSecondClick,
|
|
14742
|
+
set: (value) => {
|
|
14743
|
+
toggleContent.disableOnSecondClick = value;
|
|
14744
|
+
}
|
|
14745
|
+
});
|
|
14746
|
+
control.onStatusChange = toggleContent.onStatusChange;
|
|
14747
|
+
return control;
|
|
14748
|
+
}
|
|
14749
|
+
|
|
14750
|
+
var __defProp$d = Object.defineProperty;
|
|
14751
|
+
var __defProps$6 = Object.defineProperties;
|
|
14752
|
+
var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
|
|
14753
|
+
var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
|
|
14754
|
+
var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
|
|
14755
|
+
var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
|
|
14756
|
+
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
14757
|
+
var __spreadValues$9 = (a, b) => {
|
|
14758
|
+
for (var prop in b || (b = {}))
|
|
14759
|
+
if (__hasOwnProp$9.call(b, prop))
|
|
14760
|
+
__defNormalProp$d(a, prop, b[prop]);
|
|
14761
|
+
if (__getOwnPropSymbols$9)
|
|
14762
|
+
for (var prop of __getOwnPropSymbols$9(b)) {
|
|
14763
|
+
if (__propIsEnum$9.call(b, prop))
|
|
14764
|
+
__defNormalProp$d(a, prop, b[prop]);
|
|
14765
|
+
}
|
|
14766
|
+
return a;
|
|
14767
|
+
};
|
|
14768
|
+
var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
|
|
14769
|
+
var __publicField$9 = (obj, key, value) => __defNormalProp$d(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
14770
|
+
class LeafletControlContainer {
|
|
14771
|
+
constructor(map, options = {}) {
|
|
14772
|
+
__publicField$9(this, "map");
|
|
14773
|
+
__publicField$9(this, "controlContainer");
|
|
14774
|
+
__publicField$9(this, "targets", /* @__PURE__ */ new WeakMap());
|
|
14775
|
+
__publicField$9(this, "ids", /* @__PURE__ */ new WeakMap());
|
|
14776
|
+
this.map = map;
|
|
14777
|
+
this.controlContainer = this.createControlContainer(options);
|
|
14778
|
+
this.controlContainer.addTo(map.getContainer());
|
|
14779
|
+
}
|
|
14780
|
+
addControl(control, position, options = {}) {
|
|
14781
|
+
const targetPosition = typeof position === "string" ? position : "top-left";
|
|
14782
|
+
control.options.position = targetPosition.replace(
|
|
14783
|
+
"-",
|
|
14784
|
+
""
|
|
14785
|
+
);
|
|
14786
|
+
this.map.addControl(control);
|
|
14787
|
+
const container = control.getContainer();
|
|
14788
|
+
if (container) {
|
|
14789
|
+
this.controlContainer.append(container, position, options.order, control);
|
|
14790
|
+
this.targets.set(control, container);
|
|
14791
|
+
if (options.id) {
|
|
14792
|
+
this.controlContainer.registerIDContainer(
|
|
14793
|
+
options.id,
|
|
14794
|
+
container,
|
|
14795
|
+
control
|
|
14796
|
+
);
|
|
14797
|
+
this.ids.set(control, options.id);
|
|
14798
|
+
}
|
|
14799
|
+
}
|
|
14800
|
+
return control;
|
|
14801
|
+
}
|
|
14802
|
+
removeControl(control) {
|
|
14803
|
+
this.map.removeControl(control);
|
|
14804
|
+
const id = this.ids.get(control);
|
|
14805
|
+
if (id) {
|
|
14806
|
+
this.controlContainer.unregisterIDContainer(id);
|
|
14807
|
+
this.ids.delete(control);
|
|
14808
|
+
}
|
|
14809
|
+
const target = this.targets.get(control);
|
|
14810
|
+
if (target) {
|
|
14811
|
+
this.controlContainer.removeTarget(target);
|
|
14812
|
+
this.targets.delete(control);
|
|
14813
|
+
}
|
|
14814
|
+
}
|
|
14815
|
+
append(element, position, order = 0) {
|
|
14816
|
+
this.controlContainer.append(element, position, order);
|
|
14817
|
+
}
|
|
14818
|
+
registerIDContainer(id, controlRoot, control) {
|
|
14819
|
+
this.controlContainer.registerIDContainer(id, controlRoot, control);
|
|
14820
|
+
}
|
|
14821
|
+
unregisterIDContainer(id) {
|
|
14822
|
+
this.controlContainer.unregisterIDContainer(id);
|
|
14823
|
+
}
|
|
14824
|
+
detach() {
|
|
14825
|
+
this.controlContainer.detach();
|
|
14826
|
+
}
|
|
14827
|
+
getContainer() {
|
|
14828
|
+
return this.controlContainer.getContainer();
|
|
14829
|
+
}
|
|
14830
|
+
getControlContainer() {
|
|
14831
|
+
return this.controlContainer;
|
|
14832
|
+
}
|
|
14833
|
+
createControlContainer(options) {
|
|
14834
|
+
const mapAny = this.map;
|
|
14835
|
+
const controlCorners = mapAny._controlCorners || {};
|
|
14836
|
+
const getCorner = (key, selector) => controlCorners[key] || this.map.getContainer().querySelector(selector) || void 0;
|
|
14837
|
+
return new ControlContainer(__spreadProps$6(__spreadValues$9({}, options), {
|
|
14838
|
+
map: this.map,
|
|
14839
|
+
container: mapAny._controlContainer,
|
|
14840
|
+
positionContainers: {
|
|
14841
|
+
"top-left": getCorner("topleft", ".leaflet-top.leaflet-left"),
|
|
14842
|
+
"top-right": getCorner("topright", ".leaflet-top.leaflet-right"),
|
|
14843
|
+
"bottom-left": getCorner("bottomleft", ".leaflet-bottom.leaflet-left"),
|
|
14844
|
+
"bottom-right": getCorner(
|
|
14845
|
+
"bottomright",
|
|
14846
|
+
".leaflet-bottom.leaflet-right"
|
|
14847
|
+
)
|
|
14848
|
+
}
|
|
14849
|
+
}));
|
|
14850
|
+
}
|
|
14851
|
+
}
|
|
14178
14852
|
|
|
14179
|
-
|
|
14180
|
-
map.setZoom(zoom + delta);
|
|
14181
|
-
} else {
|
|
14182
|
-
map.setZoomAround(this._lastMousePos, zoom + delta);
|
|
14183
|
-
}
|
|
14184
|
-
}
|
|
14185
|
-
});
|
|
14853
|
+
var domain;
|
|
14186
14854
|
|
|
14187
|
-
|
|
14188
|
-
|
|
14189
|
-
|
|
14190
|
-
|
|
14855
|
+
// This constructor is used to store event handlers. Instantiating this is
|
|
14856
|
+
// faster than explicitly calling `Object.create(null)` to get a "clean" empty
|
|
14857
|
+
// object (tested with v8 v4.9).
|
|
14858
|
+
function EventHandlers() {}
|
|
14859
|
+
EventHandlers.prototype = Object.create(null);
|
|
14191
14860
|
|
|
14192
|
-
|
|
14193
|
-
|
|
14194
|
-
|
|
14861
|
+
function EventEmitter() {
|
|
14862
|
+
EventEmitter.init.call(this);
|
|
14863
|
+
}
|
|
14195
14864
|
|
|
14196
|
-
|
|
14197
|
-
|
|
14198
|
-
|
|
14199
|
-
// @section Touch interaction options
|
|
14200
|
-
// @option tap: Boolean = true
|
|
14201
|
-
// Enables mobile hacks for supporting instant taps (fixing 200ms click
|
|
14202
|
-
// delay on iOS/Android) and touch holds (fired as `contextmenu` events).
|
|
14203
|
-
tap: true,
|
|
14865
|
+
// nodejs oddity
|
|
14866
|
+
// require('events') === require('events').EventEmitter
|
|
14867
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
14204
14868
|
|
|
14205
|
-
|
|
14206
|
-
// The max number of pixels a user can shift his finger during touch
|
|
14207
|
-
// for it to be considered a valid tap.
|
|
14208
|
-
tapTolerance: 15
|
|
14209
|
-
});
|
|
14869
|
+
EventEmitter.usingDomains = false;
|
|
14210
14870
|
|
|
14211
|
-
|
|
14212
|
-
|
|
14213
|
-
|
|
14214
|
-
},
|
|
14871
|
+
EventEmitter.prototype.domain = undefined;
|
|
14872
|
+
EventEmitter.prototype._events = undefined;
|
|
14873
|
+
EventEmitter.prototype._maxListeners = undefined;
|
|
14215
14874
|
|
|
14216
|
-
|
|
14217
|
-
|
|
14218
|
-
|
|
14875
|
+
// By default EventEmitters will print a warning if more than 10 listeners are
|
|
14876
|
+
// added to it. This is a useful default which helps finding memory leaks.
|
|
14877
|
+
EventEmitter.defaultMaxListeners = 10;
|
|
14219
14878
|
|
|
14220
|
-
|
|
14221
|
-
|
|
14879
|
+
EventEmitter.init = function() {
|
|
14880
|
+
this.domain = null;
|
|
14881
|
+
if (EventEmitter.usingDomains) {
|
|
14882
|
+
// if there is an active domain, then attach to it.
|
|
14883
|
+
if (domain.active && !(this instanceof domain.Domain)) {
|
|
14884
|
+
this.domain = domain.active;
|
|
14885
|
+
}
|
|
14886
|
+
}
|
|
14222
14887
|
|
|
14223
|
-
|
|
14888
|
+
if (!this._events || this._events === Object.getPrototypeOf(this)._events) {
|
|
14889
|
+
this._events = new EventHandlers();
|
|
14890
|
+
this._eventsCount = 0;
|
|
14891
|
+
}
|
|
14224
14892
|
|
|
14225
|
-
|
|
14893
|
+
this._maxListeners = this._maxListeners || undefined;
|
|
14894
|
+
};
|
|
14226
14895
|
|
|
14227
|
-
|
|
14228
|
-
|
|
14229
|
-
|
|
14230
|
-
|
|
14231
|
-
|
|
14232
|
-
|
|
14896
|
+
// Obviously not all Emitters should be limited to 10. This function allows
|
|
14897
|
+
// that to be increased. Set to zero for unlimited.
|
|
14898
|
+
EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
|
|
14899
|
+
if (typeof n !== 'number' || n < 0 || isNaN(n))
|
|
14900
|
+
throw new TypeError('"n" argument must be a positive number');
|
|
14901
|
+
this._maxListeners = n;
|
|
14902
|
+
return this;
|
|
14903
|
+
};
|
|
14233
14904
|
|
|
14234
|
-
|
|
14235
|
-
|
|
14905
|
+
function $getMaxListeners(that) {
|
|
14906
|
+
if (that._maxListeners === undefined)
|
|
14907
|
+
return EventEmitter.defaultMaxListeners;
|
|
14908
|
+
return that._maxListeners;
|
|
14909
|
+
}
|
|
14236
14910
|
|
|
14237
|
-
|
|
14911
|
+
EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
|
|
14912
|
+
return $getMaxListeners(this);
|
|
14913
|
+
};
|
|
14238
14914
|
|
|
14239
|
-
|
|
14240
|
-
|
|
14241
|
-
|
|
14242
|
-
|
|
14915
|
+
// These standalone emit* functions are used to optimize calling of event
|
|
14916
|
+
// handlers for fast cases because emit() itself often has a variable number of
|
|
14917
|
+
// arguments and can be deoptimized because of that. These functions always have
|
|
14918
|
+
// the same number of arguments and thus do not get deoptimized, so the code
|
|
14919
|
+
// inside them can execute faster.
|
|
14920
|
+
function emitNone(handler, isFn, self) {
|
|
14921
|
+
if (isFn)
|
|
14922
|
+
handler.call(self);
|
|
14923
|
+
else {
|
|
14924
|
+
var len = handler.length;
|
|
14925
|
+
var listeners = arrayClone(handler, len);
|
|
14926
|
+
for (var i = 0; i < len; ++i)
|
|
14927
|
+
listeners[i].call(self);
|
|
14928
|
+
}
|
|
14929
|
+
}
|
|
14930
|
+
function emitOne(handler, isFn, self, arg1) {
|
|
14931
|
+
if (isFn)
|
|
14932
|
+
handler.call(self, arg1);
|
|
14933
|
+
else {
|
|
14934
|
+
var len = handler.length;
|
|
14935
|
+
var listeners = arrayClone(handler, len);
|
|
14936
|
+
for (var i = 0; i < len; ++i)
|
|
14937
|
+
listeners[i].call(self, arg1);
|
|
14938
|
+
}
|
|
14939
|
+
}
|
|
14940
|
+
function emitTwo(handler, isFn, self, arg1, arg2) {
|
|
14941
|
+
if (isFn)
|
|
14942
|
+
handler.call(self, arg1, arg2);
|
|
14943
|
+
else {
|
|
14944
|
+
var len = handler.length;
|
|
14945
|
+
var listeners = arrayClone(handler, len);
|
|
14946
|
+
for (var i = 0; i < len; ++i)
|
|
14947
|
+
listeners[i].call(self, arg1, arg2);
|
|
14948
|
+
}
|
|
14949
|
+
}
|
|
14950
|
+
function emitThree(handler, isFn, self, arg1, arg2, arg3) {
|
|
14951
|
+
if (isFn)
|
|
14952
|
+
handler.call(self, arg1, arg2, arg3);
|
|
14953
|
+
else {
|
|
14954
|
+
var len = handler.length;
|
|
14955
|
+
var listeners = arrayClone(handler, len);
|
|
14956
|
+
for (var i = 0; i < len; ++i)
|
|
14957
|
+
listeners[i].call(self, arg1, arg2, arg3);
|
|
14958
|
+
}
|
|
14959
|
+
}
|
|
14243
14960
|
|
|
14244
|
-
|
|
14245
|
-
|
|
14246
|
-
|
|
14247
|
-
|
|
14248
|
-
|
|
14249
|
-
|
|
14250
|
-
|
|
14251
|
-
|
|
14961
|
+
function emitMany(handler, isFn, self, args) {
|
|
14962
|
+
if (isFn)
|
|
14963
|
+
handler.apply(self, args);
|
|
14964
|
+
else {
|
|
14965
|
+
var len = handler.length;
|
|
14966
|
+
var listeners = arrayClone(handler, len);
|
|
14967
|
+
for (var i = 0; i < len; ++i)
|
|
14968
|
+
listeners[i].apply(self, args);
|
|
14969
|
+
}
|
|
14970
|
+
}
|
|
14252
14971
|
|
|
14253
|
-
|
|
14972
|
+
EventEmitter.prototype.emit = function emit(type) {
|
|
14973
|
+
var er, handler, len, args, i, events, domain;
|
|
14974
|
+
var doError = (type === 'error');
|
|
14254
14975
|
|
|
14255
|
-
|
|
14256
|
-
|
|
14257
|
-
|
|
14258
|
-
|
|
14259
|
-
|
|
14976
|
+
events = this._events;
|
|
14977
|
+
if (events)
|
|
14978
|
+
doError = (doError && events.error == null);
|
|
14979
|
+
else if (!doError)
|
|
14980
|
+
return false;
|
|
14260
14981
|
|
|
14261
|
-
|
|
14262
|
-
clearTimeout(this._holdTimeout);
|
|
14982
|
+
domain = this.domain;
|
|
14263
14983
|
|
|
14264
|
-
|
|
14265
|
-
|
|
14266
|
-
|
|
14267
|
-
|
|
14984
|
+
// If there is no 'error' event listener then throw.
|
|
14985
|
+
if (doError) {
|
|
14986
|
+
er = arguments[1];
|
|
14987
|
+
if (domain) {
|
|
14988
|
+
if (!er)
|
|
14989
|
+
er = new Error('Uncaught, unspecified "error" event');
|
|
14990
|
+
er.domainEmitter = this;
|
|
14991
|
+
er.domain = domain;
|
|
14992
|
+
er.domainThrown = false;
|
|
14993
|
+
domain.emit('error', er);
|
|
14994
|
+
} else if (er instanceof Error) {
|
|
14995
|
+
throw er; // Unhandled 'error' event
|
|
14996
|
+
} else {
|
|
14997
|
+
// At least give some kind of context to the user
|
|
14998
|
+
var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
|
|
14999
|
+
err.context = er;
|
|
15000
|
+
throw err;
|
|
15001
|
+
}
|
|
15002
|
+
return false;
|
|
15003
|
+
}
|
|
14268
15004
|
|
|
14269
|
-
|
|
15005
|
+
handler = events[type];
|
|
14270
15006
|
|
|
14271
|
-
|
|
14272
|
-
|
|
15007
|
+
if (!handler)
|
|
15008
|
+
return false;
|
|
14273
15009
|
|
|
14274
|
-
|
|
14275
|
-
|
|
14276
|
-
|
|
15010
|
+
var isFn = typeof handler === 'function';
|
|
15011
|
+
len = arguments.length;
|
|
15012
|
+
switch (len) {
|
|
15013
|
+
// fast cases
|
|
15014
|
+
case 1:
|
|
15015
|
+
emitNone(handler, isFn, this);
|
|
15016
|
+
break;
|
|
15017
|
+
case 2:
|
|
15018
|
+
emitOne(handler, isFn, this, arguments[1]);
|
|
15019
|
+
break;
|
|
15020
|
+
case 3:
|
|
15021
|
+
emitTwo(handler, isFn, this, arguments[1], arguments[2]);
|
|
15022
|
+
break;
|
|
15023
|
+
case 4:
|
|
15024
|
+
emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
|
|
15025
|
+
break;
|
|
15026
|
+
// slower
|
|
15027
|
+
default:
|
|
15028
|
+
args = new Array(len - 1);
|
|
15029
|
+
for (i = 1; i < len; i++)
|
|
15030
|
+
args[i - 1] = arguments[i];
|
|
15031
|
+
emitMany(handler, isFn, this, args);
|
|
15032
|
+
}
|
|
14277
15033
|
|
|
14278
|
-
|
|
15034
|
+
return true;
|
|
15035
|
+
};
|
|
14279
15036
|
|
|
14280
|
-
|
|
14281
|
-
|
|
14282
|
-
|
|
14283
|
-
|
|
14284
|
-
}
|
|
14285
|
-
},
|
|
15037
|
+
function _addListener(target, type, listener, prepend) {
|
|
15038
|
+
var m;
|
|
15039
|
+
var events;
|
|
15040
|
+
var existing;
|
|
14286
15041
|
|
|
14287
|
-
|
|
14288
|
-
|
|
14289
|
-
},
|
|
15042
|
+
if (typeof listener !== 'function')
|
|
15043
|
+
throw new TypeError('"listener" argument must be a function');
|
|
14290
15044
|
|
|
14291
|
-
|
|
14292
|
-
|
|
14293
|
-
|
|
14294
|
-
|
|
14295
|
-
|
|
15045
|
+
events = target._events;
|
|
15046
|
+
if (!events) {
|
|
15047
|
+
events = target._events = new EventHandlers();
|
|
15048
|
+
target._eventsCount = 0;
|
|
15049
|
+
} else {
|
|
15050
|
+
// To avoid recursion in the case that type === "newListener"! Before
|
|
15051
|
+
// adding it to the listeners, first emit "newListener".
|
|
15052
|
+
if (events.newListener) {
|
|
15053
|
+
target.emit('newListener', type,
|
|
15054
|
+
listener.listener ? listener.listener : listener);
|
|
14296
15055
|
|
|
14297
|
-
|
|
14298
|
-
|
|
15056
|
+
// Re-assign `events` because a newListener handler could have caused the
|
|
15057
|
+
// this._events to be assigned to a new object
|
|
15058
|
+
events = target._events;
|
|
15059
|
+
}
|
|
15060
|
+
existing = events[type];
|
|
15061
|
+
}
|
|
14299
15062
|
|
|
14300
|
-
|
|
14301
|
-
|
|
15063
|
+
if (!existing) {
|
|
15064
|
+
// Optimize the case of one listener. Don't need the extra array object.
|
|
15065
|
+
existing = events[type] = listener;
|
|
15066
|
+
++target._eventsCount;
|
|
15067
|
+
} else {
|
|
15068
|
+
if (typeof existing === 'function') {
|
|
15069
|
+
// Adding the second element, need to change to array.
|
|
15070
|
+
existing = events[type] = prepend ? [listener, existing] :
|
|
15071
|
+
[existing, listener];
|
|
15072
|
+
} else {
|
|
15073
|
+
// If we've already got an array, just append.
|
|
15074
|
+
if (prepend) {
|
|
15075
|
+
existing.unshift(listener);
|
|
15076
|
+
} else {
|
|
15077
|
+
existing.push(listener);
|
|
15078
|
+
}
|
|
15079
|
+
}
|
|
14302
15080
|
|
|
14303
|
-
|
|
14304
|
-
|
|
14305
|
-
|
|
14306
|
-
|
|
14307
|
-
|
|
15081
|
+
// Check for listener leak
|
|
15082
|
+
if (!existing.warned) {
|
|
15083
|
+
m = $getMaxListeners(target);
|
|
15084
|
+
if (m && m > 0 && existing.length > m) {
|
|
15085
|
+
existing.warned = true;
|
|
15086
|
+
var w = new Error('Possible EventEmitter memory leak detected. ' +
|
|
15087
|
+
existing.length + ' ' + type + ' listeners added. ' +
|
|
15088
|
+
'Use emitter.setMaxListeners() to increase limit');
|
|
15089
|
+
w.name = 'MaxListenersExceededWarning';
|
|
15090
|
+
w.emitter = target;
|
|
15091
|
+
w.type = type;
|
|
15092
|
+
w.count = existing.length;
|
|
15093
|
+
emitWarning(w);
|
|
15094
|
+
}
|
|
15095
|
+
}
|
|
15096
|
+
}
|
|
14308
15097
|
|
|
14309
|
-
|
|
14310
|
-
|
|
14311
|
-
|
|
15098
|
+
return target;
|
|
15099
|
+
}
|
|
15100
|
+
function emitWarning(e) {
|
|
15101
|
+
typeof console.warn === 'function' ? console.warn(e) : console.log(e);
|
|
15102
|
+
}
|
|
15103
|
+
EventEmitter.prototype.addListener = function addListener(type, listener) {
|
|
15104
|
+
return _addListener(this, type, listener, false);
|
|
15105
|
+
};
|
|
14312
15106
|
|
|
14313
|
-
|
|
14314
|
-
// @property tap: Handler
|
|
14315
|
-
// Mobile touch hacks (quick tap and touch hold) handler.
|
|
14316
|
-
if (touch && (!pointer || safari)) {
|
|
14317
|
-
Map.addInitHook('addHandler', 'tap', Tap);
|
|
14318
|
-
}
|
|
15107
|
+
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
|
14319
15108
|
|
|
14320
|
-
|
|
14321
|
-
|
|
14322
|
-
|
|
15109
|
+
EventEmitter.prototype.prependListener =
|
|
15110
|
+
function prependListener(type, listener) {
|
|
15111
|
+
return _addListener(this, type, listener, true);
|
|
15112
|
+
};
|
|
14323
15113
|
|
|
14324
|
-
|
|
14325
|
-
|
|
14326
|
-
|
|
14327
|
-
|
|
14328
|
-
|
|
14329
|
-
|
|
14330
|
-
|
|
14331
|
-
|
|
14332
|
-
|
|
14333
|
-
|
|
15114
|
+
function _onceWrap(target, type, listener) {
|
|
15115
|
+
var fired = false;
|
|
15116
|
+
function g() {
|
|
15117
|
+
target.removeListener(type, g);
|
|
15118
|
+
if (!fired) {
|
|
15119
|
+
fired = true;
|
|
15120
|
+
listener.apply(target, arguments);
|
|
15121
|
+
}
|
|
15122
|
+
}
|
|
15123
|
+
g.listener = listener;
|
|
15124
|
+
return g;
|
|
15125
|
+
}
|
|
14334
15126
|
|
|
14335
|
-
|
|
14336
|
-
|
|
14337
|
-
|
|
14338
|
-
|
|
14339
|
-
|
|
15127
|
+
EventEmitter.prototype.once = function once(type, listener) {
|
|
15128
|
+
if (typeof listener !== 'function')
|
|
15129
|
+
throw new TypeError('"listener" argument must be a function');
|
|
15130
|
+
this.on(type, _onceWrap(this, type, listener));
|
|
15131
|
+
return this;
|
|
15132
|
+
};
|
|
14340
15133
|
|
|
14341
|
-
|
|
14342
|
-
|
|
14343
|
-
|
|
14344
|
-
|
|
14345
|
-
|
|
15134
|
+
EventEmitter.prototype.prependOnceListener =
|
|
15135
|
+
function prependOnceListener(type, listener) {
|
|
15136
|
+
if (typeof listener !== 'function')
|
|
15137
|
+
throw new TypeError('"listener" argument must be a function');
|
|
15138
|
+
this.prependListener(type, _onceWrap(this, type, listener));
|
|
15139
|
+
return this;
|
|
15140
|
+
};
|
|
14346
15141
|
|
|
14347
|
-
|
|
14348
|
-
|
|
14349
|
-
|
|
14350
|
-
|
|
15142
|
+
// emits a 'removeListener' event iff the listener was removed
|
|
15143
|
+
EventEmitter.prototype.removeListener =
|
|
15144
|
+
function removeListener(type, listener) {
|
|
15145
|
+
var list, events, position, i, originalListener;
|
|
14351
15146
|
|
|
14352
|
-
|
|
14353
|
-
|
|
14354
|
-
if (!e.touches || e.touches.length !== 2 || map._animatingZoom || this._zooming) { return; }
|
|
15147
|
+
if (typeof listener !== 'function')
|
|
15148
|
+
throw new TypeError('"listener" argument must be a function');
|
|
14355
15149
|
|
|
14356
|
-
|
|
14357
|
-
|
|
15150
|
+
events = this._events;
|
|
15151
|
+
if (!events)
|
|
15152
|
+
return this;
|
|
14358
15153
|
|
|
14359
|
-
|
|
14360
|
-
|
|
14361
|
-
|
|
14362
|
-
this._pinchStartLatLng = map.containerPointToLatLng(p1.add(p2)._divideBy(2));
|
|
14363
|
-
}
|
|
15154
|
+
list = events[type];
|
|
15155
|
+
if (!list)
|
|
15156
|
+
return this;
|
|
14364
15157
|
|
|
14365
|
-
|
|
14366
|
-
|
|
15158
|
+
if (list === listener || (list.listener && list.listener === listener)) {
|
|
15159
|
+
if (--this._eventsCount === 0)
|
|
15160
|
+
this._events = new EventHandlers();
|
|
15161
|
+
else {
|
|
15162
|
+
delete events[type];
|
|
15163
|
+
if (events.removeListener)
|
|
15164
|
+
this.emit('removeListener', type, list.listener || listener);
|
|
15165
|
+
}
|
|
15166
|
+
} else if (typeof list !== 'function') {
|
|
15167
|
+
position = -1;
|
|
14367
15168
|
|
|
14368
|
-
|
|
14369
|
-
|
|
15169
|
+
for (i = list.length; i-- > 0;) {
|
|
15170
|
+
if (list[i] === listener ||
|
|
15171
|
+
(list[i].listener && list[i].listener === listener)) {
|
|
15172
|
+
originalListener = list[i].listener;
|
|
15173
|
+
position = i;
|
|
15174
|
+
break;
|
|
15175
|
+
}
|
|
15176
|
+
}
|
|
14370
15177
|
|
|
14371
|
-
|
|
15178
|
+
if (position < 0)
|
|
15179
|
+
return this;
|
|
14372
15180
|
|
|
14373
|
-
|
|
14374
|
-
|
|
15181
|
+
if (list.length === 1) {
|
|
15182
|
+
list[0] = undefined;
|
|
15183
|
+
if (--this._eventsCount === 0) {
|
|
15184
|
+
this._events = new EventHandlers();
|
|
15185
|
+
return this;
|
|
15186
|
+
} else {
|
|
15187
|
+
delete events[type];
|
|
15188
|
+
}
|
|
15189
|
+
} else {
|
|
15190
|
+
spliceOne(list, position);
|
|
15191
|
+
}
|
|
14375
15192
|
|
|
14376
|
-
|
|
14377
|
-
|
|
15193
|
+
if (events.removeListener)
|
|
15194
|
+
this.emit('removeListener', type, originalListener || listener);
|
|
15195
|
+
}
|
|
14378
15196
|
|
|
14379
|
-
|
|
14380
|
-
|
|
15197
|
+
return this;
|
|
15198
|
+
};
|
|
15199
|
+
|
|
15200
|
+
// Alias for removeListener added in NodeJS 10.0
|
|
15201
|
+
// https://nodejs.org/api/events.html#events_emitter_off_eventname_listener
|
|
15202
|
+
EventEmitter.prototype.off = function(type, listener){
|
|
15203
|
+
return this.removeListener(type, listener);
|
|
15204
|
+
};
|
|
14381
15205
|
|
|
14382
|
-
|
|
14383
|
-
|
|
14384
|
-
|
|
14385
|
-
scale = p1.distanceTo(p2) / this._startDist;
|
|
15206
|
+
EventEmitter.prototype.removeAllListeners =
|
|
15207
|
+
function removeAllListeners(type) {
|
|
15208
|
+
var listeners, events;
|
|
14386
15209
|
|
|
14387
|
-
|
|
15210
|
+
events = this._events;
|
|
15211
|
+
if (!events)
|
|
15212
|
+
return this;
|
|
14388
15213
|
|
|
14389
|
-
|
|
14390
|
-
|
|
14391
|
-
|
|
14392
|
-
|
|
14393
|
-
|
|
15214
|
+
// not listening for removeListener, no need to emit
|
|
15215
|
+
if (!events.removeListener) {
|
|
15216
|
+
if (arguments.length === 0) {
|
|
15217
|
+
this._events = new EventHandlers();
|
|
15218
|
+
this._eventsCount = 0;
|
|
15219
|
+
} else if (events[type]) {
|
|
15220
|
+
if (--this._eventsCount === 0)
|
|
15221
|
+
this._events = new EventHandlers();
|
|
15222
|
+
else
|
|
15223
|
+
delete events[type];
|
|
15224
|
+
}
|
|
15225
|
+
return this;
|
|
15226
|
+
}
|
|
14394
15227
|
|
|
14395
|
-
|
|
14396
|
-
|
|
14397
|
-
|
|
14398
|
-
|
|
14399
|
-
|
|
14400
|
-
|
|
14401
|
-
|
|
14402
|
-
|
|
14403
|
-
|
|
15228
|
+
// emit removeListener for all listeners on all events
|
|
15229
|
+
if (arguments.length === 0) {
|
|
15230
|
+
var keys = Object.keys(events);
|
|
15231
|
+
for (var i = 0, key; i < keys.length; ++i) {
|
|
15232
|
+
key = keys[i];
|
|
15233
|
+
if (key === 'removeListener') continue;
|
|
15234
|
+
this.removeAllListeners(key);
|
|
15235
|
+
}
|
|
15236
|
+
this.removeAllListeners('removeListener');
|
|
15237
|
+
this._events = new EventHandlers();
|
|
15238
|
+
this._eventsCount = 0;
|
|
15239
|
+
return this;
|
|
15240
|
+
}
|
|
14404
15241
|
|
|
14405
|
-
|
|
14406
|
-
map._moveStart(true, false);
|
|
14407
|
-
this._moved = true;
|
|
14408
|
-
}
|
|
15242
|
+
listeners = events[type];
|
|
14409
15243
|
|
|
14410
|
-
|
|
15244
|
+
if (typeof listeners === 'function') {
|
|
15245
|
+
this.removeListener(type, listeners);
|
|
15246
|
+
} else if (listeners) {
|
|
15247
|
+
// LIFO order
|
|
15248
|
+
do {
|
|
15249
|
+
this.removeListener(type, listeners[listeners.length - 1]);
|
|
15250
|
+
} while (listeners[0]);
|
|
15251
|
+
}
|
|
14411
15252
|
|
|
14412
|
-
|
|
14413
|
-
|
|
15253
|
+
return this;
|
|
15254
|
+
};
|
|
14414
15255
|
|
|
14415
|
-
|
|
14416
|
-
|
|
15256
|
+
EventEmitter.prototype.listeners = function listeners(type) {
|
|
15257
|
+
var evlistener;
|
|
15258
|
+
var ret;
|
|
15259
|
+
var events = this._events;
|
|
14417
15260
|
|
|
14418
|
-
|
|
14419
|
-
|
|
14420
|
-
|
|
14421
|
-
|
|
14422
|
-
|
|
15261
|
+
if (!events)
|
|
15262
|
+
ret = [];
|
|
15263
|
+
else {
|
|
15264
|
+
evlistener = events[type];
|
|
15265
|
+
if (!evlistener)
|
|
15266
|
+
ret = [];
|
|
15267
|
+
else if (typeof evlistener === 'function')
|
|
15268
|
+
ret = [evlistener.listener || evlistener];
|
|
15269
|
+
else
|
|
15270
|
+
ret = unwrapListeners(evlistener);
|
|
15271
|
+
}
|
|
14423
15272
|
|
|
14424
|
-
|
|
14425
|
-
|
|
15273
|
+
return ret;
|
|
15274
|
+
};
|
|
14426
15275
|
|
|
14427
|
-
|
|
14428
|
-
|
|
15276
|
+
EventEmitter.listenerCount = function(emitter, type) {
|
|
15277
|
+
if (typeof emitter.listenerCount === 'function') {
|
|
15278
|
+
return emitter.listenerCount(type);
|
|
15279
|
+
} else {
|
|
15280
|
+
return listenerCount.call(emitter, type);
|
|
15281
|
+
}
|
|
15282
|
+
};
|
|
14429
15283
|
|
|
14430
|
-
|
|
14431
|
-
|
|
14432
|
-
|
|
14433
|
-
} else {
|
|
14434
|
-
this._map._resetView(this._center, this._map._limitZoom(this._zoom));
|
|
14435
|
-
}
|
|
14436
|
-
}
|
|
14437
|
-
});
|
|
15284
|
+
EventEmitter.prototype.listenerCount = listenerCount;
|
|
15285
|
+
function listenerCount(type) {
|
|
15286
|
+
var events = this._events;
|
|
14438
15287
|
|
|
14439
|
-
|
|
14440
|
-
|
|
14441
|
-
// Touch zoom handler.
|
|
14442
|
-
Map.addInitHook('addHandler', 'touchZoom', TouchZoom);
|
|
15288
|
+
if (events) {
|
|
15289
|
+
var evlistener = events[type];
|
|
14443
15290
|
|
|
14444
|
-
|
|
14445
|
-
|
|
14446
|
-
|
|
14447
|
-
|
|
14448
|
-
|
|
14449
|
-
|
|
14450
|
-
Map.TouchZoom = TouchZoom;
|
|
15291
|
+
if (typeof evlistener === 'function') {
|
|
15292
|
+
return 1;
|
|
15293
|
+
} else if (evlistener) {
|
|
15294
|
+
return evlistener.length;
|
|
15295
|
+
}
|
|
15296
|
+
}
|
|
14451
15297
|
|
|
14452
|
-
|
|
14453
|
-
|
|
14454
|
-
exports.control = control;
|
|
14455
|
-
exports.Browser = Browser;
|
|
14456
|
-
exports.Evented = Evented;
|
|
14457
|
-
exports.Mixin = Mixin;
|
|
14458
|
-
exports.Util = Util;
|
|
14459
|
-
exports.Class = Class;
|
|
14460
|
-
exports.Handler = Handler;
|
|
14461
|
-
exports.extend = extend;
|
|
14462
|
-
exports.bind = bind;
|
|
14463
|
-
exports.stamp = stamp;
|
|
14464
|
-
exports.setOptions = setOptions;
|
|
14465
|
-
exports.DomEvent = DomEvent;
|
|
14466
|
-
exports.DomUtil = DomUtil;
|
|
14467
|
-
exports.PosAnimation = PosAnimation;
|
|
14468
|
-
exports.Draggable = Draggable;
|
|
14469
|
-
exports.LineUtil = LineUtil;
|
|
14470
|
-
exports.PolyUtil = PolyUtil;
|
|
14471
|
-
exports.Point = Point;
|
|
14472
|
-
exports.point = toPoint;
|
|
14473
|
-
exports.Bounds = Bounds;
|
|
14474
|
-
exports.bounds = toBounds;
|
|
14475
|
-
exports.Transformation = Transformation;
|
|
14476
|
-
exports.transformation = toTransformation;
|
|
14477
|
-
exports.Projection = index;
|
|
14478
|
-
exports.LatLng = LatLng;
|
|
14479
|
-
exports.latLng = toLatLng;
|
|
14480
|
-
exports.LatLngBounds = LatLngBounds;
|
|
14481
|
-
exports.latLngBounds = toLatLngBounds;
|
|
14482
|
-
exports.CRS = CRS;
|
|
14483
|
-
exports.GeoJSON = GeoJSON;
|
|
14484
|
-
exports.geoJSON = geoJSON;
|
|
14485
|
-
exports.geoJson = geoJson;
|
|
14486
|
-
exports.Layer = Layer;
|
|
14487
|
-
exports.LayerGroup = LayerGroup;
|
|
14488
|
-
exports.layerGroup = layerGroup;
|
|
14489
|
-
exports.FeatureGroup = FeatureGroup;
|
|
14490
|
-
exports.featureGroup = featureGroup;
|
|
14491
|
-
exports.ImageOverlay = ImageOverlay;
|
|
14492
|
-
exports.imageOverlay = imageOverlay;
|
|
14493
|
-
exports.VideoOverlay = VideoOverlay;
|
|
14494
|
-
exports.videoOverlay = videoOverlay;
|
|
14495
|
-
exports.SVGOverlay = SVGOverlay;
|
|
14496
|
-
exports.svgOverlay = svgOverlay;
|
|
14497
|
-
exports.DivOverlay = DivOverlay;
|
|
14498
|
-
exports.Popup = Popup;
|
|
14499
|
-
exports.popup = popup;
|
|
14500
|
-
exports.Tooltip = Tooltip;
|
|
14501
|
-
exports.tooltip = tooltip;
|
|
14502
|
-
exports.Icon = Icon;
|
|
14503
|
-
exports.icon = icon;
|
|
14504
|
-
exports.DivIcon = DivIcon;
|
|
14505
|
-
exports.divIcon = divIcon;
|
|
14506
|
-
exports.Marker = Marker;
|
|
14507
|
-
exports.marker = marker;
|
|
14508
|
-
exports.TileLayer = TileLayer;
|
|
14509
|
-
exports.tileLayer = tileLayer;
|
|
14510
|
-
exports.GridLayer = GridLayer;
|
|
14511
|
-
exports.gridLayer = gridLayer;
|
|
14512
|
-
exports.SVG = SVG;
|
|
14513
|
-
exports.svg = svg$1;
|
|
14514
|
-
exports.Renderer = Renderer;
|
|
14515
|
-
exports.Canvas = Canvas;
|
|
14516
|
-
exports.canvas = canvas$1;
|
|
14517
|
-
exports.Path = Path;
|
|
14518
|
-
exports.CircleMarker = CircleMarker;
|
|
14519
|
-
exports.circleMarker = circleMarker;
|
|
14520
|
-
exports.Circle = Circle;
|
|
14521
|
-
exports.circle = circle;
|
|
14522
|
-
exports.Polyline = Polyline;
|
|
14523
|
-
exports.polyline = polyline;
|
|
14524
|
-
exports.Polygon = Polygon;
|
|
14525
|
-
exports.polygon = polygon;
|
|
14526
|
-
exports.Rectangle = Rectangle;
|
|
14527
|
-
exports.rectangle = rectangle;
|
|
14528
|
-
exports.Map = Map;
|
|
14529
|
-
exports.map = createMap;
|
|
15298
|
+
return 0;
|
|
15299
|
+
}
|
|
14530
15300
|
|
|
14531
|
-
|
|
14532
|
-
|
|
14533
|
-
|
|
14534
|
-
return this;
|
|
14535
|
-
};
|
|
15301
|
+
EventEmitter.prototype.eventNames = function eventNames() {
|
|
15302
|
+
return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
|
|
15303
|
+
};
|
|
14536
15304
|
|
|
14537
|
-
|
|
14538
|
-
|
|
15305
|
+
// About 1.5x faster than the two-arg version of Array#splice().
|
|
15306
|
+
function spliceOne(list, index) {
|
|
15307
|
+
for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
|
|
15308
|
+
list[i] = list[k];
|
|
15309
|
+
list.pop();
|
|
15310
|
+
}
|
|
14539
15311
|
|
|
14540
|
-
|
|
14541
|
-
|
|
14542
|
-
|
|
14543
|
-
|
|
15312
|
+
function arrayClone(arr, i) {
|
|
15313
|
+
var copy = new Array(i);
|
|
15314
|
+
while (i--)
|
|
15315
|
+
copy[i] = arr[i];
|
|
15316
|
+
return copy;
|
|
14544
15317
|
}
|
|
14545
15318
|
|
|
14546
|
-
|
|
15319
|
+
function unwrapListeners(arr) {
|
|
15320
|
+
var ret = new Array(arr.length);
|
|
15321
|
+
for (var i = 0; i < ret.length; ++i) {
|
|
15322
|
+
ret[i] = arr[i].listener || arr[i];
|
|
15323
|
+
}
|
|
15324
|
+
return ret;
|
|
15325
|
+
}
|
|
14547
15326
|
|
|
14548
15327
|
class AttributionControl extends leafletSrcExports.Control.Attribution {
|
|
14549
15328
|
// options: AttributionControlOptions
|
|
@@ -14562,81 +15341,6 @@ class AttributionControl extends leafletSrcExports.Control.Attribution {
|
|
|
14562
15341
|
}
|
|
14563
15342
|
}
|
|
14564
15343
|
|
|
14565
|
-
function createControl(control, options = {}, map) {
|
|
14566
|
-
const C = leafletSrcExports.Control.extend({
|
|
14567
|
-
onAdd() {
|
|
14568
|
-
const element = document.createElement("div");
|
|
14569
|
-
const content = control.onAdd(map);
|
|
14570
|
-
element.classList.add("leaflet-control");
|
|
14571
|
-
if (options.bar) {
|
|
14572
|
-
element.classList.add("leaflet-bar");
|
|
14573
|
-
}
|
|
14574
|
-
if (options.addClass) {
|
|
14575
|
-
element.classList.add(options.addClass);
|
|
14576
|
-
}
|
|
14577
|
-
if (!options.margin && !options.bar) {
|
|
14578
|
-
element.style.marginBottom = "0px";
|
|
14579
|
-
element.style.marginTop = "0px";
|
|
14580
|
-
element.style.marginLeft = "0px";
|
|
14581
|
-
element.style.marginRight = "0px";
|
|
14582
|
-
}
|
|
14583
|
-
if (content) {
|
|
14584
|
-
element.appendChild(content);
|
|
14585
|
-
}
|
|
14586
|
-
leafletSrcExports.DomEvent.disableClickPropagation(element);
|
|
14587
|
-
return element;
|
|
14588
|
-
},
|
|
14589
|
-
onRemove() {
|
|
14590
|
-
control.onRemove();
|
|
14591
|
-
}
|
|
14592
|
-
});
|
|
14593
|
-
return new C();
|
|
14594
|
-
}
|
|
14595
|
-
|
|
14596
|
-
function createButtonControl(options, map) {
|
|
14597
|
-
const link = document.createElement("a");
|
|
14598
|
-
const title = options.title || "";
|
|
14599
|
-
link.href = "#";
|
|
14600
|
-
link.title = title;
|
|
14601
|
-
link.setAttribute("role", "button");
|
|
14602
|
-
link.setAttribute("aria-label", title);
|
|
14603
|
-
if (options.addClass) {
|
|
14604
|
-
link.classList.add(options.addClass);
|
|
14605
|
-
}
|
|
14606
|
-
leafletSrcExports.DomEvent.disableClickPropagation(link);
|
|
14607
|
-
leafletSrcExports.DomEvent.on(link, "click", leafletSrcExports.DomEvent.stop);
|
|
14608
|
-
if (options.html instanceof HTMLElement) {
|
|
14609
|
-
link.appendChild(options.html);
|
|
14610
|
-
} else if (typeof options.html === "string") {
|
|
14611
|
-
link.innerHTML = options.html;
|
|
14612
|
-
}
|
|
14613
|
-
const onClick = (e) => {
|
|
14614
|
-
e.stopPropagation();
|
|
14615
|
-
options.onClick();
|
|
14616
|
-
};
|
|
14617
|
-
return createControl(
|
|
14618
|
-
{
|
|
14619
|
-
onAdd() {
|
|
14620
|
-
if (options.onClick !== void 0) {
|
|
14621
|
-
link.addEventListener("click", onClick);
|
|
14622
|
-
}
|
|
14623
|
-
return link;
|
|
14624
|
-
},
|
|
14625
|
-
onRemove() {
|
|
14626
|
-
const parent = link.parentNode;
|
|
14627
|
-
if (parent) {
|
|
14628
|
-
parent.removeChild(link);
|
|
14629
|
-
}
|
|
14630
|
-
if (options.onClick !== void 0) {
|
|
14631
|
-
link.removeEventListener("click", onClick);
|
|
14632
|
-
}
|
|
14633
|
-
}
|
|
14634
|
-
},
|
|
14635
|
-
{ bar: true },
|
|
14636
|
-
map
|
|
14637
|
-
);
|
|
14638
|
-
}
|
|
14639
|
-
|
|
14640
15344
|
function debounce(cb, wait = 10) {
|
|
14641
15345
|
let timeoutId;
|
|
14642
15346
|
function wrapper(...args) {
|
|
@@ -16351,6 +17055,7 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
|
|
|
16351
17055
|
__publicField(this, "emitter", new EventEmitter());
|
|
16352
17056
|
__publicField(this, "map");
|
|
16353
17057
|
__publicField(this, "_resizeObserver");
|
|
17058
|
+
__publicField(this, "_controlContainer");
|
|
16354
17059
|
__publicField(this, "_unselectCb", []);
|
|
16355
17060
|
__publicField(this, "_universalEvents", [
|
|
16356
17061
|
"move",
|
|
@@ -16389,6 +17094,7 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
|
|
|
16389
17094
|
this._updateMinZoomForBounds(minZoom);
|
|
16390
17095
|
this._watchSizeChangeToUpdateMinZoom();
|
|
16391
17096
|
const defPane = this.map.createPane("order-0");
|
|
17097
|
+
this._controlContainer = new LeafletControlContainer(this.map);
|
|
16392
17098
|
this.map._addUnselectCb = (def) => {
|
|
16393
17099
|
this._addUnselectCb(def);
|
|
16394
17100
|
};
|
|
@@ -16401,12 +17107,19 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
|
|
|
16401
17107
|
if (this.map) {
|
|
16402
17108
|
this.map.remove();
|
|
16403
17109
|
}
|
|
17110
|
+
if (this._controlContainer) {
|
|
17111
|
+
this._controlContainer.detach();
|
|
17112
|
+
this._controlContainer = void 0;
|
|
17113
|
+
}
|
|
16404
17114
|
this._stopWatchSizeChangeToUpdateMinZoom();
|
|
16405
17115
|
}
|
|
16406
17116
|
getContainer() {
|
|
16407
17117
|
return this.map && this.map.getContainer();
|
|
16408
17118
|
}
|
|
16409
17119
|
getControlContainer() {
|
|
17120
|
+
if (this._controlContainer) {
|
|
17121
|
+
return this._controlContainer.getContainer();
|
|
17122
|
+
}
|
|
16410
17123
|
const controlContainer = this.map && this.map._controlContainer;
|
|
16411
17124
|
if (controlContainer) {
|
|
16412
17125
|
return controlContainer;
|
|
@@ -16520,16 +17233,17 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
|
|
|
16520
17233
|
createButtonControl(options) {
|
|
16521
17234
|
return createButtonControl(options, this);
|
|
16522
17235
|
}
|
|
16523
|
-
|
|
16524
|
-
|
|
16525
|
-
|
|
16526
|
-
|
|
16527
|
-
|
|
17236
|
+
createToggleControl(options) {
|
|
17237
|
+
return createToggleControl(options, this);
|
|
17238
|
+
}
|
|
17239
|
+
addControl(control, position, options) {
|
|
17240
|
+
if (this._controlContainer) {
|
|
17241
|
+
return this._controlContainer.addControl(control, position, options);
|
|
16528
17242
|
}
|
|
16529
17243
|
}
|
|
16530
17244
|
removeControl(control) {
|
|
16531
|
-
if (this.
|
|
16532
|
-
this.
|
|
17245
|
+
if (this._controlContainer) {
|
|
17246
|
+
this._controlContainer.removeControl(control);
|
|
16533
17247
|
}
|
|
16534
17248
|
}
|
|
16535
17249
|
removeLayer(layer) {
|