@nextgis/leaflet-map-adapter 1.19.4 → 2.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.
@@ -1,78 +1,39 @@
1
- /** Bundle of @nextgis/leaflet-map-adapter; version: 1.19.4; author: NextGIS */
2
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
3
-
4
- var events = {exports: {}};
5
-
6
- var R = typeof Reflect === 'object' ? Reflect : null;
7
- var ReflectApply = R && typeof R.apply === 'function'
8
- ? R.apply
9
- : function ReflectApply(target, receiver, args) {
10
- return Function.prototype.apply.call(target, receiver, args);
11
- };
12
-
13
- var ReflectOwnKeys;
14
- if (R && typeof R.ownKeys === 'function') {
15
- ReflectOwnKeys = R.ownKeys;
16
- } else if (Object.getOwnPropertySymbols) {
17
- ReflectOwnKeys = function ReflectOwnKeys(target) {
18
- return Object.getOwnPropertyNames(target)
19
- .concat(Object.getOwnPropertySymbols(target));
20
- };
21
- } else {
22
- ReflectOwnKeys = function ReflectOwnKeys(target) {
23
- return Object.getOwnPropertyNames(target);
24
- };
25
- }
1
+ /** Bundle of @nextgis/leaflet-map-adapter; version: 2.0.0-alpha.0; author: NextGIS */
2
+ var domain;
26
3
 
27
- function ProcessEmitWarning(warning) {
28
- if (console && console.warn) console.warn(warning);
29
- }
30
-
31
- var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
32
- return value !== value;
33
- };
4
+ // This constructor is used to store event handlers. Instantiating this is
5
+ // faster than explicitly calling `Object.create(null)` to get a "clean" empty
6
+ // object (tested with v8 v4.9).
7
+ function EventHandlers() {}
8
+ EventHandlers.prototype = Object.create(null);
34
9
 
35
10
  function EventEmitter() {
36
11
  EventEmitter.init.call(this);
37
12
  }
38
- events.exports = EventEmitter;
39
- events.exports.once = once;
40
13
 
41
- // Backwards-compat with node 0.10.x
14
+ // nodejs oddity
15
+ // require('events') === require('events').EventEmitter
42
16
  EventEmitter.EventEmitter = EventEmitter;
43
17
 
18
+ EventEmitter.usingDomains = false;
19
+
20
+ EventEmitter.prototype.domain = undefined;
44
21
  EventEmitter.prototype._events = undefined;
45
- EventEmitter.prototype._eventsCount = 0;
46
22
  EventEmitter.prototype._maxListeners = undefined;
47
23
 
48
24
  // By default EventEmitters will print a warning if more than 10 listeners are
49
25
  // added to it. This is a useful default which helps finding memory leaks.
50
- var defaultMaxListeners = 10;
51
-
52
- function checkListener(listener) {
53
- if (typeof listener !== 'function') {
54
- throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
55
- }
56
- }
57
-
58
- Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
59
- enumerable: true,
60
- get: function() {
61
- return defaultMaxListeners;
62
- },
63
- set: function(arg) {
64
- if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
65
- throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
66
- }
67
- defaultMaxListeners = arg;
68
- }
69
- });
26
+ EventEmitter.defaultMaxListeners = 10;
70
27
 
71
28
  EventEmitter.init = function() {
29
+ this.domain = null;
30
+ if (EventEmitter.usingDomains) {
31
+ // if there is an active domain, then attach to it.
32
+ if (domain.active ) ;
33
+ }
72
34
 
73
- if (this._events === undefined ||
74
- this._events === Object.getPrototypeOf(this)._events) {
75
- this._events = Object.create(null);
35
+ if (!this._events || this._events === Object.getPrototypeOf(this)._events) {
36
+ this._events = new EventHandlers();
76
37
  this._eventsCount = 0;
77
38
  }
78
39
 
@@ -82,62 +43,139 @@ EventEmitter.init = function() {
82
43
  // Obviously not all Emitters should be limited to 10. This function allows
83
44
  // that to be increased. Set to zero for unlimited.
84
45
  EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
85
- if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
86
- throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
87
- }
46
+ if (typeof n !== 'number' || n < 0 || isNaN(n))
47
+ throw new TypeError('"n" argument must be a positive number');
88
48
  this._maxListeners = n;
89
49
  return this;
90
50
  };
91
51
 
92
- function _getMaxListeners(that) {
52
+ function $getMaxListeners(that) {
93
53
  if (that._maxListeners === undefined)
94
54
  return EventEmitter.defaultMaxListeners;
95
55
  return that._maxListeners;
96
56
  }
97
57
 
98
58
  EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
99
- return _getMaxListeners(this);
59
+ return $getMaxListeners(this);
100
60
  };
101
61
 
62
+ // These standalone emit* functions are used to optimize calling of event
63
+ // handlers for fast cases because emit() itself often has a variable number of
64
+ // arguments and can be deoptimized because of that. These functions always have
65
+ // the same number of arguments and thus do not get deoptimized, so the code
66
+ // inside them can execute faster.
67
+ function emitNone(handler, isFn, self) {
68
+ if (isFn)
69
+ handler.call(self);
70
+ else {
71
+ var len = handler.length;
72
+ var listeners = arrayClone(handler, len);
73
+ for (var i = 0; i < len; ++i)
74
+ listeners[i].call(self);
75
+ }
76
+ }
77
+ function emitOne(handler, isFn, self, arg1) {
78
+ if (isFn)
79
+ handler.call(self, arg1);
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);
85
+ }
86
+ }
87
+ function emitTwo(handler, isFn, self, arg1, arg2) {
88
+ if (isFn)
89
+ handler.call(self, arg1, arg2);
90
+ else {
91
+ var len = handler.length;
92
+ var listeners = arrayClone(handler, len);
93
+ for (var i = 0; i < len; ++i)
94
+ listeners[i].call(self, arg1, arg2);
95
+ }
96
+ }
97
+ function emitThree(handler, isFn, self, arg1, arg2, arg3) {
98
+ if (isFn)
99
+ handler.call(self, arg1, arg2, arg3);
100
+ else {
101
+ var len = handler.length;
102
+ var listeners = arrayClone(handler, len);
103
+ for (var i = 0; i < len; ++i)
104
+ listeners[i].call(self, arg1, arg2, arg3);
105
+ }
106
+ }
107
+
108
+ function emitMany(handler, isFn, self, args) {
109
+ if (isFn)
110
+ handler.apply(self, args);
111
+ else {
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);
116
+ }
117
+ }
118
+
102
119
  EventEmitter.prototype.emit = function emit(type) {
103
- var args = [];
104
- for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
120
+ var er, handler, len, args, i, events, domain;
105
121
  var doError = (type === 'error');
106
122
 
107
- var events = this._events;
108
- if (events !== undefined)
109
- doError = (doError && events.error === undefined);
123
+ events = this._events;
124
+ if (events)
125
+ doError = (doError && events.error == null);
110
126
  else if (!doError)
111
127
  return false;
112
128
 
129
+ domain = this.domain;
130
+
113
131
  // If there is no 'error' event listener then throw.
114
132
  if (doError) {
115
- var er;
116
- if (args.length > 0)
117
- er = args[0];
118
- if (er instanceof Error) {
119
- // Note: The comments on the `throw` lines are intentional, they show
120
- // up in Node's output if this results in an unhandled exception.
133
+ er = arguments[1];
134
+ if (domain) {
135
+ if (!er)
136
+ er = new Error('Uncaught, unspecified "error" event');
137
+ er.domainEmitter = this;
138
+ er.domain = domain;
139
+ er.domainThrown = false;
140
+ domain.emit('error', er);
141
+ } else if (er instanceof Error) {
121
142
  throw er; // Unhandled 'error' event
143
+ } else {
144
+ // At least give some kind of context to the user
145
+ var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
146
+ err.context = er;
147
+ throw err;
122
148
  }
123
- // At least give some kind of context to the user
124
- var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
125
- err.context = er;
126
- throw err; // Unhandled 'error' event
149
+ return false;
127
150
  }
128
151
 
129
- var handler = events[type];
152
+ handler = events[type];
130
153
 
131
- if (handler === undefined)
154
+ if (!handler)
132
155
  return false;
133
156
 
134
- if (typeof handler === 'function') {
135
- ReflectApply(handler, this, args);
136
- } else {
137
- var len = handler.length;
138
- var listeners = arrayClone(handler, len);
139
- for (var i = 0; i < len; ++i)
140
- ReflectApply(listeners[i], this, args);
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);
141
179
  }
142
180
 
143
181
  return true;
@@ -148,16 +186,17 @@ function _addListener(target, type, listener, prepend) {
148
186
  var events;
149
187
  var existing;
150
188
 
151
- checkListener(listener);
189
+ if (typeof listener !== 'function')
190
+ throw new TypeError('"listener" argument must be a function');
152
191
 
153
192
  events = target._events;
154
- if (events === undefined) {
155
- events = target._events = Object.create(null);
193
+ if (!events) {
194
+ events = target._events = new EventHandlers();
156
195
  target._eventsCount = 0;
157
196
  } else {
158
197
  // To avoid recursion in the case that type === "newListener"! Before
159
198
  // adding it to the listeners, first emit "newListener".
160
- if (events.newListener !== undefined) {
199
+ if (events.newListener) {
161
200
  target.emit('newListener', type,
162
201
  listener.listener ? listener.listener : listener);
163
202
 
@@ -168,43 +207,46 @@ function _addListener(target, type, listener, prepend) {
168
207
  existing = events[type];
169
208
  }
170
209
 
171
- if (existing === undefined) {
210
+ if (!existing) {
172
211
  // Optimize the case of one listener. Don't need the extra array object.
173
212
  existing = events[type] = listener;
174
213
  ++target._eventsCount;
175
214
  } else {
176
215
  if (typeof existing === 'function') {
177
216
  // Adding the second element, need to change to array.
178
- existing = events[type] =
179
- prepend ? [listener, existing] : [existing, listener];
180
- // If we've already got an array, just append.
181
- } else if (prepend) {
182
- existing.unshift(listener);
217
+ existing = events[type] = prepend ? [listener, existing] :
218
+ [existing, listener];
183
219
  } else {
184
- existing.push(listener);
220
+ // If we've already got an array, just append.
221
+ if (prepend) {
222
+ existing.unshift(listener);
223
+ } else {
224
+ existing.push(listener);
225
+ }
185
226
  }
186
227
 
187
228
  // Check for listener leak
188
- m = _getMaxListeners(target);
189
- if (m > 0 && existing.length > m && !existing.warned) {
190
- existing.warned = true;
191
- // No error code for this since it is a Warning
192
- // eslint-disable-next-line no-restricted-syntax
193
- var w = new Error('Possible EventEmitter memory leak detected. ' +
194
- existing.length + ' ' + String(type) + ' listeners ' +
195
- 'added. Use emitter.setMaxListeners() to ' +
196
- 'increase limit');
197
- w.name = 'MaxListenersExceededWarning';
198
- w.emitter = target;
199
- w.type = type;
200
- w.count = existing.length;
201
- ProcessEmitWarning(w);
229
+ if (!existing.warned) {
230
+ m = $getMaxListeners(target);
231
+ if (m && m > 0 && existing.length > m) {
232
+ existing.warned = true;
233
+ var w = new Error('Possible EventEmitter memory leak detected. ' +
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);
241
+ }
202
242
  }
203
243
  }
204
244
 
205
245
  return target;
206
246
  }
207
-
247
+ function emitWarning(e) {
248
+ typeof console.warn === 'function' ? console.warn(e) : console.log(e);
249
+ }
208
250
  EventEmitter.prototype.addListener = function addListener(type, listener) {
209
251
  return _addListener(this, type, listener, false);
210
252
  };
@@ -216,55 +258,53 @@ EventEmitter.prototype.prependListener =
216
258
  return _addListener(this, type, listener, true);
217
259
  };
218
260
 
219
- function onceWrapper() {
220
- if (!this.fired) {
221
- this.target.removeListener(this.type, this.wrapFn);
222
- this.fired = true;
223
- if (arguments.length === 0)
224
- return this.listener.call(this.target);
225
- return this.listener.apply(this.target, arguments);
226
- }
227
- }
228
-
229
261
  function _onceWrap(target, type, listener) {
230
- var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
231
- var wrapped = onceWrapper.bind(state);
232
- wrapped.listener = listener;
233
- state.wrapFn = wrapped;
234
- return wrapped;
262
+ var fired = false;
263
+ function g() {
264
+ target.removeListener(type, g);
265
+ if (!fired) {
266
+ fired = true;
267
+ listener.apply(target, arguments);
268
+ }
269
+ }
270
+ g.listener = listener;
271
+ return g;
235
272
  }
236
273
 
237
274
  EventEmitter.prototype.once = function once(type, listener) {
238
- checkListener(listener);
275
+ if (typeof listener !== 'function')
276
+ throw new TypeError('"listener" argument must be a function');
239
277
  this.on(type, _onceWrap(this, type, listener));
240
278
  return this;
241
279
  };
242
280
 
243
281
  EventEmitter.prototype.prependOnceListener =
244
282
  function prependOnceListener(type, listener) {
245
- checkListener(listener);
283
+ if (typeof listener !== 'function')
284
+ throw new TypeError('"listener" argument must be a function');
246
285
  this.prependListener(type, _onceWrap(this, type, listener));
247
286
  return this;
248
287
  };
249
288
 
250
- // Emits a 'removeListener' event if and only if the listener was removed.
289
+ // emits a 'removeListener' event iff the listener was removed
251
290
  EventEmitter.prototype.removeListener =
252
291
  function removeListener(type, listener) {
253
292
  var list, events, position, i, originalListener;
254
293
 
255
- checkListener(listener);
294
+ if (typeof listener !== 'function')
295
+ throw new TypeError('"listener" argument must be a function');
256
296
 
257
297
  events = this._events;
258
- if (events === undefined)
298
+ if (!events)
259
299
  return this;
260
300
 
261
301
  list = events[type];
262
- if (list === undefined)
302
+ if (!list)
263
303
  return this;
264
304
 
265
- if (list === listener || list.listener === listener) {
305
+ if (list === listener || (list.listener && list.listener === listener)) {
266
306
  if (--this._eventsCount === 0)
267
- this._events = Object.create(null);
307
+ this._events = new EventHandlers();
268
308
  else {
269
309
  delete events[type];
270
310
  if (events.removeListener)
@@ -273,8 +313,9 @@ EventEmitter.prototype.removeListener =
273
313
  } else if (typeof list !== 'function') {
274
314
  position = -1;
275
315
 
276
- for (i = list.length - 1; i >= 0; i--) {
277
- if (list[i] === listener || list[i].listener === listener) {
316
+ for (i = list.length; i-- > 0;) {
317
+ if (list[i] === listener ||
318
+ (list[i].listener && list[i].listener === listener)) {
278
319
  originalListener = list[i].listener;
279
320
  position = i;
280
321
  break;
@@ -284,40 +325,47 @@ EventEmitter.prototype.removeListener =
284
325
  if (position < 0)
285
326
  return this;
286
327
 
287
- if (position === 0)
288
- list.shift();
289
- else {
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 {
290
337
  spliceOne(list, position);
291
338
  }
292
339
 
293
- if (list.length === 1)
294
- events[type] = list[0];
295
-
296
- if (events.removeListener !== undefined)
340
+ if (events.removeListener)
297
341
  this.emit('removeListener', type, originalListener || listener);
298
342
  }
299
343
 
300
344
  return this;
301
345
  };
302
-
303
- EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
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
+ };
304
352
 
305
353
  EventEmitter.prototype.removeAllListeners =
306
354
  function removeAllListeners(type) {
307
- var listeners, events, i;
355
+ var listeners, events;
308
356
 
309
357
  events = this._events;
310
- if (events === undefined)
358
+ if (!events)
311
359
  return this;
312
360
 
313
361
  // not listening for removeListener, no need to emit
314
- if (events.removeListener === undefined) {
362
+ if (!events.removeListener) {
315
363
  if (arguments.length === 0) {
316
- this._events = Object.create(null);
364
+ this._events = new EventHandlers();
317
365
  this._eventsCount = 0;
318
- } else if (events[type] !== undefined) {
366
+ } else if (events[type]) {
319
367
  if (--this._eventsCount === 0)
320
- this._events = Object.create(null);
368
+ this._events = new EventHandlers();
321
369
  else
322
370
  delete events[type];
323
371
  }
@@ -327,14 +375,13 @@ EventEmitter.prototype.removeAllListeners =
327
375
  // emit removeListener for all listeners on all events
328
376
  if (arguments.length === 0) {
329
377
  var keys = Object.keys(events);
330
- var key;
331
- for (i = 0; i < keys.length; ++i) {
378
+ for (var i = 0, key; i < keys.length; ++i) {
332
379
  key = keys[i];
333
380
  if (key === 'removeListener') continue;
334
381
  this.removeAllListeners(key);
335
382
  }
336
383
  this.removeAllListeners('removeListener');
337
- this._events = Object.create(null);
384
+ this._events = new EventHandlers();
338
385
  this._eventsCount = 0;
339
386
  return this;
340
387
  }
@@ -343,39 +390,34 @@ EventEmitter.prototype.removeAllListeners =
343
390
 
344
391
  if (typeof listeners === 'function') {
345
392
  this.removeListener(type, listeners);
346
- } else if (listeners !== undefined) {
393
+ } else if (listeners) {
347
394
  // LIFO order
348
- for (i = listeners.length - 1; i >= 0; i--) {
349
- this.removeListener(type, listeners[i]);
350
- }
395
+ do {
396
+ this.removeListener(type, listeners[listeners.length - 1]);
397
+ } while (listeners[0]);
351
398
  }
352
399
 
353
400
  return this;
354
401
  };
355
402
 
356
- function _listeners(target, type, unwrap) {
357
- var events = target._events;
358
-
359
- if (events === undefined)
360
- return [];
361
-
362
- var evlistener = events[type];
363
- if (evlistener === undefined)
364
- return [];
365
-
366
- if (typeof evlistener === 'function')
367
- return unwrap ? [evlistener.listener || evlistener] : [evlistener];
368
-
369
- return unwrap ?
370
- unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
371
- }
372
-
373
403
  EventEmitter.prototype.listeners = function listeners(type) {
374
- return _listeners(this, type, true);
375
- };
404
+ var evlistener;
405
+ var ret;
406
+ var events = this._events;
407
+
408
+ if (!events)
409
+ ret = [];
410
+ else {
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
+ }
376
419
 
377
- EventEmitter.prototype.rawListeners = function rawListeners(type) {
378
- return _listeners(this, type, false);
420
+ return ret;
379
421
  };
380
422
 
381
423
  EventEmitter.listenerCount = function(emitter, type) {
@@ -390,12 +432,12 @@ EventEmitter.prototype.listenerCount = listenerCount;
390
432
  function listenerCount(type) {
391
433
  var events = this._events;
392
434
 
393
- if (events !== undefined) {
435
+ if (events) {
394
436
  var evlistener = events[type];
395
437
 
396
438
  if (typeof evlistener === 'function') {
397
439
  return 1;
398
- } else if (evlistener !== undefined) {
440
+ } else if (evlistener) {
399
441
  return evlistener.length;
400
442
  }
401
443
  }
@@ -404,22 +446,23 @@ function listenerCount(type) {
404
446
  }
405
447
 
406
448
  EventEmitter.prototype.eventNames = function eventNames() {
407
- return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
449
+ return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
408
450
  };
409
451
 
410
- function arrayClone(arr, n) {
411
- var copy = new Array(n);
412
- for (var i = 0; i < n; ++i)
413
- copy[i] = arr[i];
414
- return copy;
415
- }
416
-
452
+ // About 1.5x faster than the two-arg version of Array#splice().
417
453
  function spliceOne(list, index) {
418
- for (; index + 1 < list.length; index++)
419
- list[index] = list[index + 1];
454
+ for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
455
+ list[i] = list[k];
420
456
  list.pop();
421
457
  }
422
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
+
423
466
  function unwrapListeners(arr) {
424
467
  var ret = new Array(arr.length);
425
468
  for (var i = 0; i < ret.length; ++i) {
@@ -428,54 +471,7 @@ function unwrapListeners(arr) {
428
471
  return ret;
429
472
  }
430
473
 
431
- function once(emitter, name) {
432
- return new Promise(function (resolve, reject) {
433
- function errorListener(err) {
434
- emitter.removeListener(name, resolver);
435
- reject(err);
436
- }
437
-
438
- function resolver() {
439
- if (typeof emitter.removeListener === 'function') {
440
- emitter.removeListener('error', errorListener);
441
- }
442
- resolve([].slice.call(arguments));
443
- }
444
- eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
445
- if (name !== 'error') {
446
- addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
447
- }
448
- });
449
- }
450
-
451
- function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
452
- if (typeof emitter.on === 'function') {
453
- eventTargetAgnosticAddListener(emitter, 'error', handler, flags);
454
- }
455
- }
456
-
457
- function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
458
- if (typeof emitter.on === 'function') {
459
- if (flags.once) {
460
- emitter.once(name, listener);
461
- } else {
462
- emitter.on(name, listener);
463
- }
464
- } else if (typeof emitter.addEventListener === 'function') {
465
- // EventTarget does not have `error` event semantics like Node
466
- // EventEmitters, we do not listen for `error` events here.
467
- emitter.addEventListener(name, function wrapListener(arg) {
468
- // IE does not have builtin `{ once: true }` support so we
469
- // have to do it manually.
470
- if (flags.once) {
471
- emitter.removeEventListener(name, wrapListener);
472
- }
473
- listener(arg);
474
- });
475
- } else {
476
- throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
477
- }
478
- }
474
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
479
475
 
480
476
  var leafletSrc = {exports: {}};
481
477
 
@@ -14541,1744 +14537,1967 @@ var leafletSrc = {exports: {}};
14541
14537
 
14542
14538
  } (leafletSrc, leafletSrc.exports));
14543
14539
 
14544
- class AttributionControl extends leafletSrc.exports.Control.Attribution {
14545
- // options: AttributionControlOptions
14546
- constructor(options) {
14547
- super(options);
14548
- const customAttribution = options && options.customAttribution;
14549
- if (customAttribution) {
14550
- let attributions = [];
14551
- if (Array.isArray(customAttribution)) {
14552
- attributions = customAttribution;
14553
- }
14554
- else if (customAttribution) {
14555
- attributions = [customAttribution];
14556
- }
14557
- attributions.forEach((x) => this.addAttribution(x));
14558
- }
14540
+ var leafletSrcExports = leafletSrc.exports;
14541
+
14542
+ class AttributionControl extends leafletSrcExports.Control.Attribution {
14543
+ // options: AttributionControlOptions
14544
+ constructor(options) {
14545
+ super(options);
14546
+ const customAttribution = options && options.customAttribution;
14547
+ if (customAttribution) {
14548
+ let attributions = [];
14549
+ if (Array.isArray(customAttribution)) {
14550
+ attributions = customAttribution;
14551
+ } else if (customAttribution) {
14552
+ attributions = [customAttribution];
14553
+ }
14554
+ attributions.forEach((x) => this.addAttribution(x));
14559
14555
  }
14556
+ }
14560
14557
  }
14561
14558
 
14562
14559
  function createControl(control, options = {}, map) {
14563
- const C = leafletSrc.exports.Control.extend({
14564
- onAdd() {
14565
- const element = document.createElement('div');
14566
- const content = control.onAdd(map);
14567
- element.classList.add('leaflet-control');
14568
- if (options.bar) {
14569
- element.classList.add('leaflet-bar');
14570
- }
14571
- if (options.addClass) {
14572
- element.classList.add(options.addClass);
14573
- }
14574
- if (!options.margin && !options.bar) {
14575
- element.style.marginBottom = '0px';
14576
- element.style.marginTop = '0px';
14577
- element.style.marginLeft = '0px';
14578
- element.style.marginRight = '0px';
14579
- }
14580
- if (content) {
14581
- element.appendChild(content);
14582
- }
14583
- leafletSrc.exports.DomEvent.disableClickPropagation(element);
14584
- return element;
14585
- },
14586
- onRemove() {
14587
- control.onRemove();
14588
- },
14589
- });
14590
- return new C();
14560
+ const C = leafletSrcExports.Control.extend({
14561
+ onAdd() {
14562
+ const element = document.createElement("div");
14563
+ const content = control.onAdd(map);
14564
+ element.classList.add("leaflet-control");
14565
+ if (options.bar) {
14566
+ element.classList.add("leaflet-bar");
14567
+ }
14568
+ if (options.addClass) {
14569
+ element.classList.add(options.addClass);
14570
+ }
14571
+ if (!options.margin && !options.bar) {
14572
+ element.style.marginBottom = "0px";
14573
+ element.style.marginTop = "0px";
14574
+ element.style.marginLeft = "0px";
14575
+ element.style.marginRight = "0px";
14576
+ }
14577
+ if (content) {
14578
+ element.appendChild(content);
14579
+ }
14580
+ leafletSrcExports.DomEvent.disableClickPropagation(element);
14581
+ return element;
14582
+ },
14583
+ onRemove() {
14584
+ control.onRemove();
14585
+ }
14586
+ });
14587
+ return new C();
14591
14588
  }
14592
14589
 
14593
14590
  function createButtonControl(options, map) {
14594
- const link = document.createElement('a');
14595
- const title = options.title || '';
14596
- link.href = '#';
14597
- link.title = title;
14598
- link.setAttribute('role', 'button');
14599
- link.setAttribute('aria-label', title);
14600
- if (options.addClass) {
14601
- link.classList.add(options.addClass);
14602
- }
14603
- leafletSrc.exports.DomEvent.disableClickPropagation(link);
14604
- leafletSrc.exports.DomEvent.on(link, 'click', leafletSrc.exports.DomEvent.stop);
14605
- if (options.html instanceof HTMLElement) {
14606
- link.appendChild(options.html);
14607
- }
14608
- else if (typeof options.html === 'string') {
14609
- link.innerHTML = options.html;
14610
- }
14611
- const onClick = (e) => {
14612
- e.stopPropagation();
14613
- options.onClick();
14614
- };
14615
- return createControl({
14616
- onAdd() {
14617
- if (options.onClick !== undefined) {
14618
- link.addEventListener('click', onClick);
14619
- }
14620
- return link;
14621
- },
14622
- onRemove() {
14623
- const parent = link.parentNode;
14624
- if (parent) {
14625
- parent.removeChild(link);
14626
- }
14627
- if (options.onClick !== undefined) {
14628
- link.removeEventListener('click', onClick);
14629
- }
14630
- },
14631
- }, { bar: true }, map);
14591
+ const link = document.createElement("a");
14592
+ const title = options.title || "";
14593
+ link.href = "#";
14594
+ link.title = title;
14595
+ link.setAttribute("role", "button");
14596
+ link.setAttribute("aria-label", title);
14597
+ if (options.addClass) {
14598
+ link.classList.add(options.addClass);
14599
+ }
14600
+ leafletSrcExports.DomEvent.disableClickPropagation(link);
14601
+ leafletSrcExports.DomEvent.on(link, "click", leafletSrcExports.DomEvent.stop);
14602
+ if (options.html instanceof HTMLElement) {
14603
+ link.appendChild(options.html);
14604
+ } else if (typeof options.html === "string") {
14605
+ link.innerHTML = options.html;
14606
+ }
14607
+ const onClick = (e) => {
14608
+ e.stopPropagation();
14609
+ options.onClick();
14610
+ };
14611
+ return createControl(
14612
+ {
14613
+ onAdd() {
14614
+ if (options.onClick !== void 0) {
14615
+ link.addEventListener("click", onClick);
14616
+ }
14617
+ return link;
14618
+ },
14619
+ onRemove() {
14620
+ const parent = link.parentNode;
14621
+ if (parent) {
14622
+ parent.removeChild(link);
14623
+ }
14624
+ if (options.onClick !== void 0) {
14625
+ link.removeEventListener("click", onClick);
14626
+ }
14627
+ }
14628
+ },
14629
+ { bar: true },
14630
+ map
14631
+ );
14632
14632
  }
14633
14633
 
14634
- /**
14635
- * from https://github.com/CesiumGS/cesium/blob/master/Source/Core/defined.js
14636
- *
14637
- * @param val - The object.
14638
- * @returns Returns true if the object is defined, returns false otherwise.
14639
- *
14640
- * @example
14641
- * ```javascript
14642
- * if (defined(positions)) {
14643
- * doSomething();
14644
- * } else {
14645
- * doSomethingElse();
14646
- * }
14647
- * ```
14648
- */
14649
14634
  function defined(val) {
14650
- return val !== undefined && val !== null;
14635
+ return val !== void 0 && val !== null;
14651
14636
  }
14652
14637
 
14653
- // based on https://github.com/bvaughn/debounce-decorator
14654
14638
  function debounce(cb, wait = 10) {
14655
- let timeoutId;
14656
- function wrapper(...args) {
14657
- wrapper.clear();
14658
- timeoutId = setTimeout(() => {
14659
- timeoutId = null;
14660
- cb.apply(this, args);
14661
- }, wait);
14639
+ let timeoutId;
14640
+ function wrapper(...args) {
14641
+ wrapper.clear();
14642
+ timeoutId = setTimeout(() => {
14643
+ timeoutId = null;
14644
+ cb.apply(this, args);
14645
+ }, wait);
14646
+ }
14647
+ wrapper.clear = function() {
14648
+ if (timeoutId) {
14649
+ clearTimeout(timeoutId);
14650
+ timeoutId = null;
14662
14651
  }
14663
- wrapper.clear = function () {
14664
- if (timeoutId) {
14665
- clearTimeout(timeoutId);
14666
- timeoutId = null;
14667
- }
14668
- };
14669
- return wrapper;
14652
+ };
14653
+ return wrapper;
14670
14654
  }
14671
14655
 
14672
14656
  function boundsToArray(bounds) {
14673
- const ne = bounds.getNorthEast();
14674
- const sw = bounds.getSouthWest();
14675
- return [sw.lng, sw.lat, ne.lng, ne.lat];
14657
+ const ne = bounds.getNorthEast();
14658
+ const sw = bounds.getSouthWest();
14659
+ return [sw.lng, sw.lat, ne.lng, ne.lat];
14676
14660
  }
14677
14661
 
14678
14662
  function findMostFrequentGeomType(arr) {
14679
- const counts = {};
14680
- for (let fry = 0; fry < arr.length; fry++) {
14681
- counts[arr[fry]] = 1 + (counts[arr[fry]] || 0);
14682
- }
14683
- let maxName = '';
14684
- for (const c in counts) {
14685
- const maxCount = maxName ? counts[maxName] : 0;
14686
- if (counts[c] > maxCount) {
14687
- maxName = c;
14688
- }
14663
+ const counts = {};
14664
+ for (let fry = 0; fry < arr.length; fry++) {
14665
+ counts[arr[fry]] = 1 + (counts[arr[fry]] || 0);
14666
+ }
14667
+ let maxName = "";
14668
+ for (const c in counts) {
14669
+ const maxCount = maxName ? counts[maxName] : 0;
14670
+ if (counts[c] > maxCount) {
14671
+ maxName = c;
14689
14672
  }
14690
- return maxName;
14673
+ }
14674
+ return maxName;
14691
14675
  }
14692
14676
  function detectType(geojson) {
14693
- let geometry;
14694
- if (geojson.type === 'FeatureCollection') {
14695
- const featuresTypes = geojson.features.map((f) => f.geometry.type);
14696
- geometry = findMostFrequentGeomType(featuresTypes);
14697
- }
14698
- else if (geojson.type === 'GeometryCollection') {
14699
- const geometryTypes = geojson.geometries.map((g) => g.type);
14700
- geometry = findMostFrequentGeomType(geometryTypes);
14701
- }
14702
- else if (geojson.type === 'Feature') {
14703
- geometry = geojson.geometry.type;
14704
- }
14705
- else {
14706
- geometry = geojson.type;
14707
- }
14708
- return geometry;
14677
+ let geometry;
14678
+ if (geojson.type === "FeatureCollection") {
14679
+ const featuresTypes = geojson.features.map(
14680
+ (f) => f.geometry.type
14681
+ );
14682
+ geometry = findMostFrequentGeomType(featuresTypes);
14683
+ } else if (geojson.type === "GeometryCollection") {
14684
+ const geometryTypes = geojson.geometries.map(
14685
+ (g) => g.type
14686
+ );
14687
+ geometry = findMostFrequentGeomType(geometryTypes);
14688
+ } else if (geojson.type === "Feature") {
14689
+ geometry = geojson.geometry.type;
14690
+ } else {
14691
+ geometry = geojson.type;
14692
+ }
14693
+ return geometry;
14709
14694
  }
14710
14695
 
14711
14696
  const typeAlias = {
14712
- Point: 'point',
14713
- LineString: 'line',
14714
- MultiPoint: 'point',
14715
- Polygon: 'polygon',
14716
- MultiLineString: 'line',
14717
- MultiPolygon: 'polygon',
14718
- GeometryCollection: 'polygon',
14697
+ Point: "point",
14698
+ LineString: "line",
14699
+ MultiPoint: "point",
14700
+ Polygon: "polygon",
14701
+ MultiLineString: "line",
14702
+ MultiPolygon: "polygon",
14703
+ GeometryCollection: "polygon"
14719
14704
  };
14720
14705
  const PAINT = {
14721
- stroke: false,
14722
- opacity: 1,
14706
+ stroke: false,
14707
+ opacity: 1
14723
14708
  };
14724
14709
  const backAliases = {};
14725
14710
  for (const a in typeAlias) {
14726
- const layerType = typeAlias[a];
14727
- const backAlias = backAliases[layerType] || [];
14728
- backAlias.push(a);
14729
- backAliases[layerType] = backAlias;
14711
+ const layerType = typeAlias[a];
14712
+ const backAlias = backAliases[layerType] || [];
14713
+ backAlias.push(a);
14714
+ backAliases[layerType] = backAlias;
14730
14715
  }
14731
14716
  function geometryFilter(geometry, type) {
14732
- const geoJsonGeometry = backAliases[type] || [];
14733
- return geoJsonGeometry.indexOf(geometry) !== -1;
14717
+ const geoJsonGeometry = backAliases[type] || [];
14718
+ return geoJsonGeometry.indexOf(geometry) !== -1;
14734
14719
  }
14735
14720
  function filterGeometries(data, type) {
14736
- if (data.type === 'FeatureCollection') {
14737
- const _data = data;
14738
- _data.features = _data.features.filter((f) => geometryFilter(f.geometry.type, type));
14739
- }
14740
- else if (data.type === 'Feature') {
14741
- const allow = geometryFilter(data.geometry.type, type);
14742
- if (!allow) {
14743
- return false;
14744
- }
14745
- }
14746
- else if (data.type === 'GeometryCollection') {
14747
- const _data = data;
14748
- _data.geometries = _data.geometries.filter((g) => geometryFilter(g.type, type));
14721
+ if (data.type === "FeatureCollection") {
14722
+ const _data = data;
14723
+ _data.features = _data.features.filter(
14724
+ (f) => geometryFilter(f.geometry.type, type)
14725
+ );
14726
+ } else if (data.type === "Feature") {
14727
+ const allow = geometryFilter(data.geometry.type, type);
14728
+ if (!allow) {
14729
+ return false;
14749
14730
  }
14750
- return data;
14731
+ } else if (data.type === "GeometryCollection") {
14732
+ const _data = data;
14733
+ _data.geometries = _data.geometries.filter(
14734
+ (g) => geometryFilter(g.type, type)
14735
+ );
14736
+ }
14737
+ return data;
14751
14738
  }
14752
14739
  function featuresBounds(features) {
14753
- const geoJsonLayer = new leafletSrc.exports.GeoJSON();
14754
- const features_ = Array.isArray(features) ? features : [features];
14755
- features_.forEach((f) => geoJsonLayer.addData(f));
14756
- return geoJsonLayer.getBounds();
14740
+ const geoJsonLayer = new leafletSrcExports.GeoJSON();
14741
+ const features_ = Array.isArray(features) ? features : [features];
14742
+ features_.forEach((f) => geoJsonLayer.addData(f));
14743
+ return geoJsonLayer.getBounds();
14757
14744
  }
14758
14745
  function getFeaturesBounds(features) {
14759
- return boundsToArray(featuresBounds(features));
14746
+ return boundsToArray(featuresBounds(features));
14760
14747
  }
14761
14748
  function getFeaturesCenter(features) {
14762
- const { lat, lng } = featuresBounds(features).getCenter();
14763
- return [lng, lat];
14749
+ const { lat, lng } = featuresBounds(features).getCenter();
14750
+ return [lng, lat];
14764
14751
  }
14765
14752
  function createFeaturePositionOptions(features) {
14766
- return {
14767
- getBounds: () => getFeaturesBounds(features),
14768
- getCenter: () => getFeaturesCenter(features),
14769
- };
14753
+ return {
14754
+ getBounds: () => getFeaturesBounds(features),
14755
+ getCenter: () => getFeaturesCenter(features)
14756
+ };
14770
14757
  }
14771
14758
 
14759
+ var __defProp$b = Object.defineProperty;
14760
+ var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14761
+ var __publicField$7 = (obj, key, value) => {
14762
+ __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
14763
+ return value;
14764
+ };
14772
14765
  class BaseAdapter {
14773
- constructor(map, options) {
14774
- this.map = map;
14775
- this.options = options;
14776
- this.pane = 'order-0';
14777
- if (options.order !== undefined) {
14778
- const pane = 'order-' + options.order;
14779
- let exist = map.getPane(pane);
14780
- if (!exist) {
14781
- exist = map.createPane(pane);
14782
- }
14783
- exist.style.zIndex = String(Math.round(options.order * 100));
14784
- this.pane = pane;
14785
- }
14786
- }
14787
- addLayer(options) {
14788
- Object.assign(this.options, options);
14789
- return undefined;
14766
+ constructor(map, options) {
14767
+ this.map = map;
14768
+ this.options = options;
14769
+ __publicField$7(this, "layer");
14770
+ __publicField$7(this, "pane", "order-0");
14771
+ if (options.order !== void 0) {
14772
+ const pane = "order-" + options.order;
14773
+ let exist = map.getPane(pane);
14774
+ if (!exist) {
14775
+ exist = map.createPane(pane);
14776
+ }
14777
+ exist.style.zIndex = String(Math.round(options.order * 100));
14778
+ this.pane = pane;
14790
14779
  }
14780
+ }
14781
+ addLayer(options) {
14782
+ Object.assign(this.options, options);
14783
+ return void 0;
14784
+ }
14791
14785
  }
14792
14786
 
14793
14787
  function convertMapClickEvent(evt) {
14794
- const coord = evt.containerPoint;
14795
- const latLng = evt.latlng;
14796
- const { lat, lng } = latLng;
14797
- return {
14798
- latLng,
14799
- lngLat: [lng, lat],
14800
- pixel: { left: coord.x, top: coord.y },
14801
- source: evt,
14802
- };
14788
+ const coord = evt.containerPoint;
14789
+ const latLng = evt.latlng;
14790
+ const { lat, lng } = latLng;
14791
+ return {
14792
+ latLng,
14793
+ lngLat: [lng, lat],
14794
+ pixel: { left: coord.x, top: coord.y },
14795
+ source: evt
14796
+ };
14803
14797
  }
14804
14798
 
14805
- function createMouseEvent({ layer, source, }) {
14806
- const layer_ = source.target;
14807
- const feature = layer_.feature;
14808
- const opt = {
14809
- layer,
14810
- feature,
14811
- event: convertMapClickEvent(source),
14812
- source,
14813
- ...createFeaturePositionOptions(feature),
14814
- };
14815
- return opt;
14799
+ var __defProp$a = Object.defineProperty;
14800
+ var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
14801
+ var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
14802
+ var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
14803
+ var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14804
+ var __spreadValues$8 = (a, b) => {
14805
+ for (var prop in b || (b = {}))
14806
+ if (__hasOwnProp$8.call(b, prop))
14807
+ __defNormalProp$a(a, prop, b[prop]);
14808
+ if (__getOwnPropSymbols$8)
14809
+ for (var prop of __getOwnPropSymbols$8(b)) {
14810
+ if (__propIsEnum$8.call(b, prop))
14811
+ __defNormalProp$a(a, prop, b[prop]);
14812
+ }
14813
+ return a;
14814
+ };
14815
+ function createMouseEvent({
14816
+ layer,
14817
+ source
14818
+ }) {
14819
+ const layer_ = source.target;
14820
+ const feature = layer_.feature;
14821
+ const opt = __spreadValues$8({
14822
+ layer,
14823
+ feature,
14824
+ event: convertMapClickEvent(source),
14825
+ source
14826
+ }, createFeaturePositionOptions(feature));
14827
+ return opt;
14816
14828
  }
14817
14829
 
14830
+ var __defProp$9 = Object.defineProperty;
14831
+ var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
14832
+ var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
14833
+ var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
14834
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14835
+ var __spreadValues$7 = (a, b) => {
14836
+ for (var prop in b || (b = {}))
14837
+ if (__hasOwnProp$7.call(b, prop))
14838
+ __defNormalProp$9(a, prop, b[prop]);
14839
+ if (__getOwnPropSymbols$7)
14840
+ for (var prop of __getOwnPropSymbols$7(b)) {
14841
+ if (__propIsEnum$7.call(b, prop))
14842
+ __defNormalProp$9(a, prop, b[prop]);
14843
+ }
14844
+ return a;
14845
+ };
14846
+ var __publicField$6 = (obj, key, value) => {
14847
+ __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
14848
+ return value;
14849
+ };
14818
14850
  class GeoJsonEvents {
14819
- constructor(layer) {
14820
- this.layer = layer;
14851
+ constructor(layer) {
14852
+ __publicField$6(this, "layer");
14853
+ __publicField$6(this, "_onclick");
14854
+ __publicField$6(this, "_mouseout");
14855
+ __publicField$6(this, "_mouseover");
14856
+ this.layer = layer;
14857
+ }
14858
+ handleMouseEvents(layer) {
14859
+ const { onClick, onLayerClick, onMouseOut, onMouseOver } = this.layer.options;
14860
+ const onClick_ = onClick || onLayerClick;
14861
+ if (onClick_) {
14862
+ this._onclick = (e) => {
14863
+ const selected = !!this.layer._getSelected(layer);
14864
+ onClick_(__spreadValues$7({
14865
+ selected
14866
+ }, this._createMouseEvent(e)));
14867
+ };
14868
+ layer.on("click", this._onclick, this);
14821
14869
  }
14822
- handleMouseEvents(layer) {
14823
- const { onClick, onLayerClick, onMouseOut, onMouseOver } = this.layer.options;
14824
- // TODO: remove backward compatibility for onLayerClick
14825
- const onClick_ = onClick || onLayerClick;
14826
- if (onClick_) {
14827
- this._onclick = (e) => {
14828
- const selected = !!this.layer._getSelected(layer);
14829
- onClick_({
14830
- selected,
14831
- ...this._createMouseEvent(e),
14832
- });
14833
- };
14834
- layer.on('click', this._onclick, this);
14835
- }
14836
- if (onMouseOut) {
14837
- this._mouseout = (e) => {
14838
- onMouseOut(this._createMouseEvent(e));
14839
- };
14840
- layer.on('mouseout', this._mouseout, this);
14841
- }
14842
- if (onMouseOver) {
14843
- this._mouseover = (e) => {
14844
- onMouseOver(this._createMouseEvent(e));
14845
- };
14846
- layer.on('mouseover', this._mouseover, this);
14847
- }
14870
+ if (onMouseOut) {
14871
+ this._mouseout = (e) => {
14872
+ onMouseOut(this._createMouseEvent(e));
14873
+ };
14874
+ layer.on("mouseout", this._mouseout, this);
14848
14875
  }
14849
- stopMouseEvents(layer) {
14850
- if (this._mouseover) {
14851
- layer.off('mouseover', this._mouseover, this);
14852
- }
14853
- if (this._mouseout) {
14854
- layer.off('mouseout', this._mouseout, this);
14855
- }
14856
- if (this._onclick) {
14857
- layer.off('click', this._onclick, this);
14858
- }
14876
+ if (onMouseOver) {
14877
+ this._mouseover = (e) => {
14878
+ onMouseOver(this._createMouseEvent(e));
14879
+ };
14880
+ layer.on("mouseover", this._mouseover, this);
14859
14881
  }
14860
- _createMouseEvent(source) {
14861
- return createMouseEvent({
14862
- layer: this.layer,
14863
- source: source,
14864
- });
14882
+ }
14883
+ stopMouseEvents(layer) {
14884
+ if (this._mouseover) {
14885
+ layer.off("mouseover", this._mouseover, this);
14886
+ }
14887
+ if (this._mouseout) {
14888
+ layer.off("mouseout", this._mouseout, this);
14865
14889
  }
14890
+ if (this._onclick) {
14891
+ layer.off("click", this._onclick, this);
14892
+ }
14893
+ }
14894
+ _createMouseEvent(source) {
14895
+ return createMouseEvent({
14896
+ layer: this.layer,
14897
+ source
14898
+ });
14899
+ }
14866
14900
  }
14867
14901
 
14868
14902
  function isPaint(paint) {
14869
- if (Object.prototype.toString.call(paint) === '[object Object]') {
14870
- return true;
14871
- }
14872
- return false;
14903
+ if (Object.prototype.toString.call(paint) === "[object Object]") {
14904
+ return true;
14905
+ }
14906
+ return false;
14873
14907
  }
14874
14908
  function isPaintCallback(paint) {
14875
- if (typeof paint === 'function') {
14876
- return true;
14877
- }
14878
- return false;
14909
+ if (typeof paint === "function") {
14910
+ return true;
14911
+ }
14912
+ return false;
14879
14913
  }
14880
14914
 
14881
- class GeoJsonPaint {
14882
- constructor(layer) {
14883
- this.layer = layer;
14884
- }
14885
- setPaintEachLayer(paint) {
14886
- this.layer._layers.forEach((layerDef) => {
14887
- this.setPaint(layerDef, paint);
14888
- });
14915
+ var __defProp$8 = Object.defineProperty;
14916
+ var __defProps$4 = Object.defineProperties;
14917
+ var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
14918
+ var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
14919
+ var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
14920
+ var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
14921
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14922
+ var __spreadValues$6 = (a, b) => {
14923
+ for (var prop in b || (b = {}))
14924
+ if (__hasOwnProp$6.call(b, prop))
14925
+ __defNormalProp$8(a, prop, b[prop]);
14926
+ if (__getOwnPropSymbols$6)
14927
+ for (var prop of __getOwnPropSymbols$6(b)) {
14928
+ if (__propIsEnum$6.call(b, prop))
14929
+ __defNormalProp$8(a, prop, b[prop]);
14889
14930
  }
14890
- setPaint(layerDef, paint) {
14891
- let style = undefined;
14892
- const { layer, feature } = layerDef;
14893
- if (layer && feature) {
14894
- if (isPaintCallback(paint)) {
14895
- style = paint(feature);
14896
- }
14897
- else if (isPaint(paint)) {
14898
- style = paint;
14899
- }
14900
- if (style) {
14901
- if (this.layer.type === 'point' && style.type === 'icon') {
14902
- const marker = layer;
14903
- const divIcon = this._createDivIcon(style);
14904
- setTimeout(() => {
14905
- marker.setIcon(divIcon);
14906
- }, 10);
14907
- }
14908
- else if ('setStyle' in layer) {
14909
- layer.setStyle(this.preparePaint(style));
14910
- }
14911
- }
14912
- }
14931
+ return a;
14932
+ };
14933
+ var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
14934
+ var __objRest$2 = (source, exclude) => {
14935
+ var target = {};
14936
+ for (var prop in source)
14937
+ if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
14938
+ target[prop] = source[prop];
14939
+ if (source != null && __getOwnPropSymbols$6)
14940
+ for (var prop of __getOwnPropSymbols$6(source)) {
14941
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
14942
+ target[prop] = source[prop];
14913
14943
  }
14914
- preparePaint(paint) {
14915
- if (paint.type !== 'get-paint') {
14916
- const paintAliases = [
14917
- ['color', 'strokeColor'],
14918
- ['opacity', 'strokeOpacity'],
14919
- ['stroke', 'stroke'],
14920
- ['fillColor', 'fillColor'],
14921
- ['fillOpacity', 'fillOpacity'],
14922
- ['fill', 'fill'],
14923
- ['weight', 'weight'],
14924
- ];
14925
- const aliases = this.layer.type === 'line'
14926
- ? [
14927
- ['color', 'strokeColor'],
14928
- ['opacity', 'strokeOpacity'],
14929
- ['weight', 'weight'],
14930
- ]
14931
- : paintAliases;
14932
- const readyPaint = {};
14933
- if ('radius' in paint && typeof paint.radius === 'number') {
14934
- readyPaint.radius = paint.radius;
14935
- }
14936
- for (const [to, from] of aliases) {
14937
- const opacity = this.layer.options.opacity;
14938
- let paintProp = paint[from];
14939
- if (defined(opacity) && from.toLowerCase().indexOf('opacity') !== -1) {
14940
- paintProp = Number(paintProp) * opacity;
14941
- }
14942
- if (paintProp !== undefined) {
14943
- Object.defineProperty(readyPaint, to, {
14944
- enumerable: true,
14945
- value: paintProp,
14946
- });
14947
- }
14948
- }
14949
- return readyPaint;
14944
+ return target;
14945
+ };
14946
+ var __publicField$5 = (obj, key, value) => {
14947
+ __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
14948
+ return value;
14949
+ };
14950
+ class GeoJsonPaint {
14951
+ constructor(layer) {
14952
+ __publicField$5(this, "layer");
14953
+ this.layer = layer;
14954
+ }
14955
+ setPaintEachLayer(paint) {
14956
+ this.layer._layers.forEach((layerDef) => {
14957
+ this.setPaint(layerDef, paint);
14958
+ });
14959
+ }
14960
+ setPaint(layerDef, paint) {
14961
+ let style = void 0;
14962
+ const { layer, feature } = layerDef;
14963
+ if (layer && feature) {
14964
+ if (isPaintCallback(paint)) {
14965
+ style = paint(feature);
14966
+ } else if (isPaint(paint)) {
14967
+ style = paint;
14968
+ }
14969
+ if (style) {
14970
+ if (this.layer.type === "point" && style.type === "icon") {
14971
+ const marker = layer;
14972
+ const divIcon = this._createDivIcon(style);
14973
+ setTimeout(() => {
14974
+ marker.setIcon(divIcon);
14975
+ }, 10);
14976
+ } else if ("setStyle" in layer) {
14977
+ layer.setStyle(this.preparePaint(style));
14950
14978
  }
14951
- return PAINT;
14979
+ }
14952
14980
  }
14953
- _createDivIcon(icon) {
14954
- const { html, rotate, className, ...toLIconOpt } = icon;
14955
- const element = document.createElement('div');
14956
- if (className) {
14957
- element.className = className;
14958
- }
14959
- if (rotate) {
14960
- element.style.transform = `rotateZ(${rotate}deg)`;
14981
+ }
14982
+ preparePaint(paint) {
14983
+ if (paint.type !== "get-paint") {
14984
+ const paintAliases = [
14985
+ ["color", "strokeColor"],
14986
+ ["opacity", "strokeOpacity"],
14987
+ ["stroke", "stroke"],
14988
+ ["fillColor", "fillColor"],
14989
+ ["fillOpacity", "fillOpacity"],
14990
+ ["fill", "fill"],
14991
+ ["weight", "weight"]
14992
+ ];
14993
+ const aliases = this.layer.type === "line" ? [
14994
+ ["color", "strokeColor"],
14995
+ ["opacity", "strokeOpacity"],
14996
+ ["weight", "weight"]
14997
+ ] : paintAliases;
14998
+ const readyPaint = {};
14999
+ if ("radius" in paint && typeof paint.radius === "number") {
15000
+ readyPaint.radius = paint.radius;
15001
+ }
15002
+ for (const [to, from] of aliases) {
15003
+ const opacity = this.layer.options.opacity;
15004
+ let paintProp = paint[from];
15005
+ if (defined(opacity) && from.toLowerCase().indexOf("opacity") !== -1) {
15006
+ paintProp = Number(paintProp) * opacity;
14961
15007
  }
14962
- if (html) {
14963
- element.innerHTML = html;
15008
+ if (paintProp !== void 0) {
15009
+ Object.defineProperty(readyPaint, to, {
15010
+ enumerable: true,
15011
+ value: paintProp
15012
+ });
14964
15013
  }
14965
- const divIcon = new leafletSrc.exports.DivIcon({
14966
- className: '',
14967
- ...toLIconOpt,
14968
- html: element,
14969
- });
14970
- return divIcon;
15014
+ }
15015
+ return readyPaint;
14971
15016
  }
14972
- createPaintToLayer(icon) {
14973
- if (icon && icon.type) {
14974
- if (icon.type === 'icon') {
14975
- const iconClassName = icon.className;
14976
- const html = icon.html;
14977
- if (iconClassName || html) {
14978
- return (_, latlng) => {
14979
- const divIcon = this._createDivIcon(icon);
14980
- return new leafletSrc.exports.Marker(latlng, { icon: divIcon });
14981
- };
14982
- }
14983
- }
14984
- else if (icon.type === 'pin') {
14985
- return (_, latlng) => {
14986
- return new leafletSrc.exports.Marker(latlng);
14987
- };
14988
- }
15017
+ return PAINT;
15018
+ }
15019
+ _createDivIcon(icon) {
15020
+ const _a = icon, { html, rotate, className } = _a, toLIconOpt = __objRest$2(_a, ["html", "rotate", "className"]);
15021
+ const element = document.createElement("div");
15022
+ if (className) {
15023
+ element.className = className;
15024
+ }
15025
+ if (rotate) {
15026
+ element.style.transform = `rotateZ(${rotate}deg)`;
15027
+ }
15028
+ if (html) {
15029
+ element.innerHTML = html;
15030
+ }
15031
+ const divIcon = new leafletSrcExports.DivIcon(__spreadProps$4(__spreadValues$6({
15032
+ className: ""
15033
+ }, toLIconOpt), {
15034
+ html: element
15035
+ }));
15036
+ return divIcon;
15037
+ }
15038
+ createPaintToLayer(icon) {
15039
+ if (icon && icon.type) {
15040
+ if (icon.type === "icon") {
15041
+ const iconClassName = icon.className;
15042
+ const html = icon.html;
15043
+ if (iconClassName || html) {
15044
+ return (_, latlng) => {
15045
+ const divIcon = this._createDivIcon(icon);
15046
+ return new leafletSrcExports.Marker(latlng, { icon: divIcon });
15047
+ };
14989
15048
  }
15049
+ } else if (icon.type === "pin") {
14990
15050
  return (_, latlng) => {
14991
- const p = PAINT;
14992
- return new leafletSrc.exports.CircleMarker(latlng, this.preparePaint({ ...p, ...icon }));
15051
+ return new leafletSrcExports.Marker(latlng);
14993
15052
  };
15053
+ }
14994
15054
  }
14995
- createPaintOptions(paint) {
14996
- const geoJsonOptions = {};
14997
- const newPaint = this.preparePaint(paint);
14998
- if (paint) {
14999
- geoJsonOptions.style = () => {
15000
- return newPaint;
15001
- };
15002
- }
15003
- if (this.layer.type === 'point') {
15004
- geoJsonOptions.pointToLayer = this.createPaintToLayer(paint);
15005
- }
15006
- else if (this.layer.type === 'line') {
15007
- newPaint.stroke = true;
15008
- }
15009
- return geoJsonOptions;
15055
+ return (_, latlng) => {
15056
+ const p = PAINT;
15057
+ return new leafletSrcExports.CircleMarker(latlng, this.preparePaint(__spreadValues$6(__spreadValues$6({}, p), icon)));
15058
+ };
15059
+ }
15060
+ createPaintOptions(paint) {
15061
+ const geoJsonOptions = {};
15062
+ const newPaint = this.preparePaint(paint);
15063
+ if (paint) {
15064
+ geoJsonOptions.style = () => {
15065
+ return newPaint;
15066
+ };
15067
+ }
15068
+ if (this.layer.type === "point") {
15069
+ geoJsonOptions.pointToLayer = this.createPaintToLayer(
15070
+ paint
15071
+ );
15072
+ } else if (this.layer.type === "line") {
15073
+ newPaint.stroke = true;
15010
15074
  }
15075
+ return geoJsonOptions;
15076
+ }
15011
15077
  }
15012
15078
 
15013
- class GeoJsonAdapter extends BaseAdapter {
15014
- constructor(map, options) {
15015
- super(map, options);
15016
- this.selected = false;
15017
- this._layers = [];
15018
- this._selectedLayers = [];
15019
- this._filteredLayers = [];
15020
- this._openedPopup = [];
15021
- this.$updateTooltip = debounce(() => {
15022
- this.updateTooltip();
15023
- }, 300);
15024
- this.$unselect = () => {
15025
- this.unselect();
15026
- };
15027
- this._events = new GeoJsonEvents(this);
15028
- this._paint = new GeoJsonPaint(this);
15029
- }
15030
- addLayer(options) {
15031
- Object.assign(this.options, options);
15032
- this.paint = options.paint;
15033
- this.layer = new leafletSrc.exports.FeatureGroup([], {
15034
- ...options.nativeOptions,
15035
- pane: this.pane,
15036
- });
15037
- this.selectedPaint = options.selectedPaint;
15038
- options.paint = this.paint;
15039
- if (options.data) {
15040
- this.addData(options.data);
15041
- }
15042
- this._addMapListener();
15043
- return this.layer;
15044
- }
15045
- beforeRemove() {
15046
- this._removeMapListener();
15079
+ var __defProp$7 = Object.defineProperty;
15080
+ var __defProps$3 = Object.defineProperties;
15081
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
15082
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
15083
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
15084
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
15085
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15086
+ var __spreadValues$5 = (a, b) => {
15087
+ for (var prop in b || (b = {}))
15088
+ if (__hasOwnProp$5.call(b, prop))
15089
+ __defNormalProp$7(a, prop, b[prop]);
15090
+ if (__getOwnPropSymbols$5)
15091
+ for (var prop of __getOwnPropSymbols$5(b)) {
15092
+ if (__propIsEnum$5.call(b, prop))
15093
+ __defNormalProp$7(a, prop, b[prop]);
15047
15094
  }
15048
- select(findFeatureFun) {
15049
- this.unselect();
15050
- if (findFeatureFun) {
15051
- const def = this._layers.filter(findFeatureFun);
15052
- for (const x of def) {
15053
- this._selectLayer(x, 'api');
15054
- }
15055
- }
15056
- else if (!this.selected) {
15057
- this.selected = true;
15058
- if (this.selectedPaint) {
15059
- this._paint.setPaintEachLayer(this.selectedPaint);
15060
- }
15061
- }
15062
- }
15063
- unselect(findFeatureFun) {
15064
- if (findFeatureFun) {
15065
- const feature = this._layers.filter(findFeatureFun);
15066
- feature.forEach((x) => {
15067
- this._unSelectLayer(x);
15068
- });
15069
- }
15070
- else if (this.selected) {
15071
- for (const p of this._openedPopup) {
15072
- this._removePopup(p[0]);
15073
- }
15074
- if (this.paint) {
15075
- this._paint.setPaintEachLayer(this.paint);
15076
- }
15077
- this._selectedLayers.length = 0;
15078
- this.selected = false;
15079
- }
15080
- }
15081
- getSelected() {
15082
- return this._selectedLayers.map((x) => {
15083
- return {
15084
- target: this,
15085
- feature: x.feature,
15086
- layer: x,
15087
- ...createFeaturePositionOptions(x.feature),
15088
- };
15089
- });
15090
- }
15091
- getFiltered() {
15092
- return this._filteredLayers;
15093
- }
15094
- filter(fun) {
15095
- // Some optimization
15096
- this._filterFun = fun;
15097
- const layer_ = this.layer;
15098
- const map = layer_ && layer_._map;
15099
- if (layer_ && map) {
15100
- layer_.remove();
15101
- const filteredLayers = [];
15102
- this._layers.forEach(({ feature, layer }) => {
15103
- if (layer) {
15104
- const ok = fun
15105
- ? fun({
15106
- target: this,
15107
- feature,
15108
- layer,
15109
- ...createFeaturePositionOptions(feature),
15110
- })
15111
- : true;
15112
- if (ok) {
15113
- layer_.addLayer(layer);
15114
- filteredLayers.push({
15115
- target: this,
15116
- feature,
15117
- layer,
15118
- ...createFeaturePositionOptions(feature),
15119
- });
15120
- }
15121
- else {
15122
- layer_.removeLayer(layer);
15123
- }
15124
- }
15125
- });
15126
- this._filteredLayers = filteredLayers;
15127
- layer_.addTo(map);
15128
- }
15129
- return this._filteredLayers;
15095
+ return a;
15096
+ };
15097
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
15098
+ var __publicField$4 = (obj, key, value) => {
15099
+ __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
15100
+ return value;
15101
+ };
15102
+ var __async = (__this, __arguments, generator) => {
15103
+ return new Promise((resolve, reject) => {
15104
+ var fulfilled = (value) => {
15105
+ try {
15106
+ step(generator.next(value));
15107
+ } catch (e) {
15108
+ reject(e);
15109
+ }
15110
+ };
15111
+ var rejected = (value) => {
15112
+ try {
15113
+ step(generator.throw(value));
15114
+ } catch (e) {
15115
+ reject(e);
15116
+ }
15117
+ };
15118
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
15119
+ step((generator = generator.apply(__this, __arguments)).next());
15120
+ });
15121
+ };
15122
+ class GeoJsonAdapter extends BaseAdapter {
15123
+ constructor(map, options) {
15124
+ super(map, options);
15125
+ __publicField$4(this, "layer");
15126
+ __publicField$4(this, "selected", false);
15127
+ __publicField$4(this, "type");
15128
+ __publicField$4(this, "_layers", []);
15129
+ __publicField$4(this, "_events");
15130
+ __publicField$4(this, "paint");
15131
+ __publicField$4(this, "selectedPaint");
15132
+ __publicField$4(this, "_selectedLayers", []);
15133
+ __publicField$4(this, "_filteredLayers", []);
15134
+ __publicField$4(this, "_filterFun");
15135
+ __publicField$4(this, "_openedPopup", []);
15136
+ __publicField$4(this, "_paint");
15137
+ __publicField$4(this, "$updateTooltip", debounce(() => {
15138
+ this.updateTooltip();
15139
+ }, 300));
15140
+ __publicField$4(this, "$unselect", () => {
15141
+ this.unselect();
15142
+ });
15143
+ this._events = new GeoJsonEvents(this);
15144
+ this._paint = new GeoJsonPaint(this);
15145
+ }
15146
+ addLayer(options) {
15147
+ Object.assign(this.options, options);
15148
+ this.paint = options.paint;
15149
+ this.layer = new leafletSrcExports.FeatureGroup([], __spreadProps$3(__spreadValues$5({}, options.nativeOptions), {
15150
+ pane: this.pane
15151
+ }));
15152
+ this.selectedPaint = options.selectedPaint;
15153
+ options.paint = this.paint;
15154
+ if (options.data) {
15155
+ this.addData(options.data);
15130
15156
  }
15131
- cleanFilter() {
15132
- this.filter();
15157
+ this._addMapListener();
15158
+ return this.layer;
15159
+ }
15160
+ beforeRemove() {
15161
+ this._removeMapListener();
15162
+ }
15163
+ select(findFeatureFun) {
15164
+ this.unselect();
15165
+ if (findFeatureFun) {
15166
+ const def = this._layers.filter(findFeatureFun);
15167
+ for (const x of def) {
15168
+ this._selectLayer(x, "api");
15169
+ }
15170
+ } else if (!this.selected) {
15171
+ this.selected = true;
15172
+ if (this.selectedPaint) {
15173
+ this._paint.setPaintEachLayer(
15174
+ this.selectedPaint
15175
+ );
15176
+ }
15133
15177
  }
15134
- getLayers() {
15135
- return this._layers.map(({ layer, feature }) => {
15136
- const visible = layer && !!layer._map;
15137
- return {
15138
- feature,
15139
- layer,
15140
- visible,
15141
- target: this,
15142
- ...createFeaturePositionOptions(feature),
15143
- };
15144
- });
15178
+ }
15179
+ unselect(findFeatureFun) {
15180
+ if (findFeatureFun) {
15181
+ const feature = this._layers.filter(findFeatureFun);
15182
+ feature.forEach((x) => {
15183
+ this._unSelectLayer(x);
15184
+ });
15185
+ } else if (this.selected) {
15186
+ for (const p of this._openedPopup) {
15187
+ this._removePopup(p[0]);
15188
+ }
15189
+ if (this.paint) {
15190
+ this._paint.setPaintEachLayer(this.paint);
15191
+ }
15192
+ this._selectedLayers.length = 0;
15193
+ this.selected = false;
15145
15194
  }
15146
- clearLayer(cb) {
15147
- this.unselect();
15148
- const layer_ = this.layer;
15149
- if (layer_) {
15150
- if (cb) {
15151
- for (let fry = this._layers.length; fry--;) {
15152
- const def = this._layers[fry];
15153
- if (def) {
15154
- const { feature, layer } = def;
15155
- if (feature && layer) {
15156
- const exist = cb(feature);
15157
- if (exist) {
15158
- layer_.removeLayer(layer);
15159
- this._layers.splice(fry, 1);
15160
- }
15161
- }
15162
- }
15163
- }
15164
- }
15165
- else {
15166
- layer_.clearLayers();
15167
- this._layers = [];
15168
- }
15195
+ }
15196
+ getSelected() {
15197
+ return this._selectedLayers.map((x) => {
15198
+ return __spreadValues$5({
15199
+ target: this,
15200
+ feature: x.feature,
15201
+ layer: x
15202
+ }, createFeaturePositionOptions(x.feature));
15203
+ });
15204
+ }
15205
+ getFiltered() {
15206
+ return this._filteredLayers;
15207
+ }
15208
+ filter(fun) {
15209
+ this._filterFun = fun;
15210
+ const layer_ = this.layer;
15211
+ const map = layer_ && layer_._map;
15212
+ if (layer_ && map) {
15213
+ layer_.remove();
15214
+ const filteredLayers = [];
15215
+ this._layers.forEach(({ feature, layer }) => {
15216
+ if (layer) {
15217
+ const ok = fun ? fun(__spreadValues$5({
15218
+ target: this,
15219
+ feature,
15220
+ layer
15221
+ }, createFeaturePositionOptions(feature))) : true;
15222
+ if (ok) {
15223
+ layer_.addLayer(layer);
15224
+ filteredLayers.push(__spreadValues$5({
15225
+ target: this,
15226
+ feature,
15227
+ layer
15228
+ }, createFeaturePositionOptions(feature)));
15229
+ } else {
15230
+ layer_.removeLayer(layer);
15231
+ }
15169
15232
  }
15233
+ });
15234
+ this._filteredLayers = filteredLayers;
15235
+ layer_.addTo(map);
15170
15236
  }
15171
- setData(data) {
15172
- this.clearLayer();
15173
- this.addData(data);
15174
- }
15175
- addData(data) {
15176
- const options = this.options;
15177
- let geoJsonOptions;
15178
- if (options) {
15179
- if (data) {
15180
- let type;
15181
- if (!options.type) {
15182
- const detectedType = detectType(data);
15183
- type = typeAlias[detectedType];
15184
- }
15185
- else {
15186
- type = options.type;
15187
- }
15188
- if (this.type && this.type !== type) {
15189
- console.warn('no other data type than layer can be added');
15190
- return;
15191
- }
15192
- this.type = type;
15193
- data = filterGeometries(data, type);
15194
- if (data) {
15195
- geoJsonOptions = this._getGeoJsonOptions(options, type);
15196
- }
15237
+ return this._filteredLayers;
15238
+ }
15239
+ cleanFilter() {
15240
+ this.filter();
15241
+ }
15242
+ getLayers() {
15243
+ return this._layers.map(({ layer, feature }) => {
15244
+ const visible = layer && !!layer._map;
15245
+ return __spreadValues$5({
15246
+ feature,
15247
+ layer,
15248
+ visible,
15249
+ target: this
15250
+ }, createFeaturePositionOptions(feature));
15251
+ });
15252
+ }
15253
+ clearLayer(cb) {
15254
+ this.unselect();
15255
+ const layer_ = this.layer;
15256
+ if (layer_) {
15257
+ if (cb) {
15258
+ for (let fry = this._layers.length; fry--; ) {
15259
+ const def = this._layers[fry];
15260
+ if (def) {
15261
+ const { feature, layer } = def;
15262
+ if (feature && layer) {
15263
+ const exist = cb(feature);
15264
+ if (exist) {
15265
+ layer_.removeLayer(layer);
15266
+ this._layers.splice(fry, 1);
15267
+ }
15197
15268
  }
15198
- new leafletSrc.exports.GeoJSON(data || undefined, geoJsonOptions);
15269
+ }
15199
15270
  }
15271
+ } else {
15272
+ layer_.clearLayers();
15273
+ this._layers = [];
15274
+ }
15200
15275
  }
15201
- openPopup(findFeatureFun, options) {
15202
- if (findFeatureFun) {
15203
- const def = this._layers.filter(findFeatureFun);
15204
- def.forEach((x) => {
15205
- this._openPopup(x, options, 'api');
15206
- });
15276
+ }
15277
+ setData(data) {
15278
+ this.clearLayer();
15279
+ this.addData(data);
15280
+ }
15281
+ addData(data) {
15282
+ const options = this.options;
15283
+ let geoJsonOptions;
15284
+ if (options) {
15285
+ if (data) {
15286
+ let type;
15287
+ if (!options.type) {
15288
+ const detectedType = detectType(data);
15289
+ type = typeAlias[detectedType];
15290
+ } else {
15291
+ type = options.type;
15207
15292
  }
15208
- }
15209
- closePopup(findFeatureFun) {
15210
- const popupToClose = findFeatureFun
15211
- ? this._openedPopup.filter((x) => findFeatureFun(x[2]))
15212
- : this._openedPopup;
15213
- popupToClose.forEach((x) => {
15214
- this._removePopup(x[0]);
15215
- });
15216
- }
15217
- updateTooltip(layerDef) {
15218
- if (layerDef) {
15219
- this._updateTooltip(layerDef);
15293
+ if (this.type && this.type !== type) {
15294
+ console.warn("no other data type than layer can be added");
15295
+ return;
15220
15296
  }
15221
- else {
15222
- this.getLayers().forEach((x) => this._updateTooltip({ feature: x.feature, layer: x.layer }));
15297
+ this.type = type;
15298
+ data = filterGeometries(data, type);
15299
+ if (data) {
15300
+ geoJsonOptions = this._getGeoJsonOptions(options, type);
15223
15301
  }
15302
+ }
15303
+ new leafletSrcExports.GeoJSON(data || void 0, geoJsonOptions);
15224
15304
  }
15225
- /** @deprecated use {@link GeoJsonAdapter.getBounds} instead */
15226
- getExtent() {
15227
- return this.getBounds();
15305
+ }
15306
+ openPopup(findFeatureFun, options) {
15307
+ if (findFeatureFun) {
15308
+ const def = this._layers.filter(findFeatureFun);
15309
+ def.forEach((x) => {
15310
+ this._openPopup(x, options, "api");
15311
+ });
15228
15312
  }
15229
- getBounds() {
15230
- if (this.layer) {
15231
- const bounds = this.layer.getBounds();
15232
- if (bounds.isValid()) {
15233
- return boundsToArray(bounds);
15234
- }
15235
- }
15313
+ }
15314
+ closePopup(findFeatureFun) {
15315
+ const popupToClose = findFeatureFun ? this._openedPopup.filter((x) => findFeatureFun(x[2])) : this._openedPopup;
15316
+ popupToClose.forEach((x) => {
15317
+ this._removePopup(x[0]);
15318
+ });
15319
+ }
15320
+ updateTooltip(layerDef) {
15321
+ if (layerDef) {
15322
+ this._updateTooltip(layerDef);
15323
+ } else {
15324
+ this.getLayers().forEach(
15325
+ (x) => this._updateTooltip({ feature: x.feature, layer: x.layer })
15326
+ );
15236
15327
  }
15237
- setOpacity(value) {
15238
- this.options.opacity = value;
15239
- this.setPaint(this.paint);
15240
- this.setSelectedPaint(this.selectedPaint);
15328
+ }
15329
+ /** @deprecated use {@link GeoJsonAdapter.getBounds} instead */
15330
+ getExtent() {
15331
+ return this.getBounds();
15332
+ }
15333
+ getBounds() {
15334
+ if (this.layer) {
15335
+ const bounds = this.layer.getBounds();
15336
+ if (bounds.isValid()) {
15337
+ return boundsToArray(bounds);
15338
+ }
15241
15339
  }
15242
- setPaint(paint) {
15243
- if (paint) {
15244
- this.paint = paint;
15245
- for (const l of this._layers) {
15246
- this._paint.setPaint(l, paint);
15247
- }
15248
- }
15340
+ }
15341
+ setOpacity(value) {
15342
+ this.options.opacity = value;
15343
+ this.setPaint(this.paint);
15344
+ this.setSelectedPaint(this.selectedPaint);
15345
+ }
15346
+ setPaint(paint) {
15347
+ if (paint) {
15348
+ this.paint = paint;
15349
+ for (const l of this._layers) {
15350
+ this._paint.setPaint(l, paint);
15351
+ }
15249
15352
  }
15250
- setSelectedPaint(paint) {
15251
- if (paint) {
15252
- this.selectedPaint = paint;
15253
- for (const l of this._selectedLayers) {
15254
- this._paint.setPaint(l, paint);
15255
- }
15256
- }
15353
+ }
15354
+ setSelectedPaint(paint) {
15355
+ if (paint) {
15356
+ this.selectedPaint = paint;
15357
+ for (const l of this._selectedLayers) {
15358
+ this._paint.setPaint(l, paint);
15359
+ }
15257
15360
  }
15258
- updatePaint(paint) {
15259
- this.paint = { ...this.paint, ...paint };
15260
- for (const l of this._layers) {
15261
- this._paint.setPaint(l, this.paint);
15262
- }
15361
+ }
15362
+ updatePaint(paint) {
15363
+ this.paint = __spreadValues$5(__spreadValues$5({}, this.paint), paint);
15364
+ for (const l of this._layers) {
15365
+ this._paint.setPaint(l, this.paint);
15263
15366
  }
15264
- updateSelectedPaint(paint) {
15265
- this.selectedPaint = { ...this.selectedPaint, ...paint };
15266
- for (const l of this._selectedLayers) {
15267
- this._paint.setPaint(l, this.selectedPaint);
15268
- }
15367
+ }
15368
+ updateSelectedPaint(paint) {
15369
+ this.selectedPaint = __spreadValues$5(__spreadValues$5({}, this.selectedPaint), paint);
15370
+ for (const l of this._selectedLayers) {
15371
+ this._paint.setPaint(l, this.selectedPaint);
15269
15372
  }
15270
- _getSelected(layer) {
15271
- return this._selectedLayers.find((x) => x.layer === layer);
15373
+ }
15374
+ _getSelected(layer) {
15375
+ return this._selectedLayers.find((x) => x.layer === layer);
15376
+ }
15377
+ _updateTooltip(layerDef) {
15378
+ const { feature, layer } = layerDef;
15379
+ const { label, labelField, labelOnHover } = this.options;
15380
+ if (layer) {
15381
+ layer.unbindTooltip();
15382
+ let message;
15383
+ if (feature.properties && labelField) {
15384
+ message = feature.properties[labelField];
15385
+ } else if (label) {
15386
+ message = label(__spreadValues$5(__spreadValues$5({
15387
+ target: this
15388
+ }, layerDef), createFeaturePositionOptions(feature)));
15389
+ }
15390
+ if (message) {
15391
+ const permanent = !labelOnHover;
15392
+ layer.bindTooltip(String(message), { permanent, sticky: false });
15393
+ }
15272
15394
  }
15273
- _updateTooltip(layerDef) {
15274
- const { feature, layer } = layerDef;
15275
- const { label, labelField, labelOnHover } = this.options;
15276
- if (layer) {
15277
- layer.unbindTooltip();
15278
- let message;
15279
- if (feature.properties && labelField) {
15280
- message = feature.properties[labelField];
15281
- }
15282
- else if (label) {
15283
- message = label({
15284
- target: this,
15285
- ...layerDef,
15286
- ...createFeaturePositionOptions(feature),
15287
- });
15288
- }
15289
- if (message) {
15290
- const permanent = !labelOnHover;
15291
- layer.bindTooltip(String(message), { permanent, sticky: false });
15292
- }
15395
+ }
15396
+ _openPopup(_0) {
15397
+ return __async(this, arguments, function* (def, options = {}, type, latLng) {
15398
+ var _a, _b;
15399
+ const { feature, layer } = def;
15400
+ const {
15401
+ minWidth,
15402
+ autoPan,
15403
+ maxWidth,
15404
+ closeButton: closeButton_
15405
+ } = __spreadValues$5({
15406
+ minWidth: 300
15407
+ }, options);
15408
+ const closeButton = closeButton_ != null ? closeButton_ : !this.options.selectOnHover;
15409
+ let popup;
15410
+ const _closeHandlers = [];
15411
+ const onClose = (handler) => {
15412
+ _closeHandlers.push(handler);
15413
+ };
15414
+ const close = () => {
15415
+ if (popup) {
15416
+ this._removePopup(popup);
15293
15417
  }
15294
- }
15295
- async _openPopup(def, options = {}, type, latLng) {
15296
- var _a, _b;
15297
- const { feature, layer } = def;
15298
- const { minWidth, autoPan, maxWidth, closeButton: closeButton_, } = {
15299
- minWidth: 300,
15300
- ...options,
15301
- };
15302
- const closeButton = closeButton_ !== null && closeButton_ !== void 0 ? closeButton_ : !this.options.selectOnHover;
15303
- let popup;
15304
- const _closeHandlers = [];
15305
- const onClose = (handler) => {
15306
- _closeHandlers.push(handler);
15307
- };
15308
- const close = () => {
15309
- if (popup) {
15310
- this._removePopup(popup);
15311
- }
15418
+ };
15419
+ let content;
15420
+ if (options.createPopupContent) {
15421
+ content = yield options.createPopupContent(__spreadValues$5({
15422
+ layer,
15423
+ feature,
15424
+ target: this,
15425
+ type,
15426
+ close,
15427
+ onClose
15428
+ }, createFeaturePositionOptions(feature)));
15429
+ } else {
15430
+ content = options.popupContent;
15431
+ }
15432
+ if (content && layer) {
15433
+ const popupOptions = {
15434
+ minWidth,
15435
+ autoPan,
15436
+ // maxWidth,
15437
+ closeButton,
15438
+ closeOnClick: false,
15439
+ autoClose: false
15312
15440
  };
15313
- let content;
15314
- if (options.createPopupContent) {
15315
- content = await options.createPopupContent({
15316
- layer,
15317
- feature,
15318
- target: this,
15319
- type,
15320
- close,
15321
- onClose,
15322
- ...createFeaturePositionOptions(feature),
15323
- });
15441
+ if (defined(maxWidth)) {
15442
+ popupOptions.maxWidth = maxWidth;
15324
15443
  }
15325
- else {
15326
- content = options.popupContent;
15444
+ popup = layer.bindPopup(content, popupOptions);
15445
+ const unselectOnClose = (_b = (_a = this.options.popupOptions) == null ? void 0 : _a.unselectOnClose) != null ? _b : true;
15446
+ if (unselectOnClose) {
15447
+ const p = layer.getPopup();
15448
+ p && p.once(
15449
+ "remove",
15450
+ () => {
15451
+ close();
15452
+ },
15453
+ this
15454
+ );
15327
15455
  }
15328
- if (content && layer) {
15329
- const popupOptions = {
15330
- minWidth,
15331
- autoPan,
15332
- // maxWidth,
15333
- closeButton,
15334
- closeOnClick: false,
15335
- autoClose: false,
15336
- };
15337
- if (defined(maxWidth)) {
15338
- popupOptions.maxWidth = maxWidth;
15339
- }
15340
- popup = layer.bindPopup(content, popupOptions);
15341
- const unselectOnClose = (_b = (_a = this.options.popupOptions) === null || _a === void 0 ? void 0 : _a.unselectOnClose) !== null && _b !== void 0 ? _b : true;
15342
- if (unselectOnClose) {
15343
- const p = layer.getPopup();
15344
- p &&
15345
- p.once('remove', () => {
15346
- close();
15347
- }, this);
15348
- }
15349
- this._openedPopup.push([popup, _closeHandlers, def]);
15350
- popup.openPopup(latLng);
15456
+ this._openedPopup.push([popup, _closeHandlers, def]);
15457
+ popup.openPopup(latLng);
15458
+ }
15459
+ });
15460
+ }
15461
+ _removePopup(popup) {
15462
+ var _a, _b;
15463
+ const map = this.map;
15464
+ if (map) {
15465
+ popup.closePopup().unbindPopup();
15466
+ const index = this._openedPopup.findIndex((x) => x[0] === popup);
15467
+ if (index !== -1) {
15468
+ const unselectOnClose = (_b = (_a = this.options.popupOptions) == null ? void 0 : _a.unselectOnClose) != null ? _b : true;
15469
+ const [, closeHandlers, def] = this._openedPopup[index];
15470
+ for (const h of closeHandlers) {
15471
+ h(def);
15351
15472
  }
15352
- }
15353
- _removePopup(popup) {
15354
- var _a, _b;
15355
- const map = this.map;
15356
- if (map) {
15357
- popup.closePopup().unbindPopup();
15358
- const index = this._openedPopup.findIndex((x) => x[0] === popup);
15359
- if (index !== -1) {
15360
- const unselectOnClose = (_b = (_a = this.options.popupOptions) === null || _a === void 0 ? void 0 : _a.unselectOnClose) !== null && _b !== void 0 ? _b : true;
15361
- const [, closeHandlers, def] = this._openedPopup[index];
15362
- for (const h of closeHandlers) {
15363
- h(def);
15364
- }
15365
- closeHandlers.length = 0;
15366
- if (unselectOnClose) {
15367
- this._unSelectLayer(def);
15368
- }
15369
- this._openedPopup.splice(index, 1);
15370
- }
15473
+ closeHandlers.length = 0;
15474
+ if (unselectOnClose) {
15475
+ this._unSelectLayer(def);
15371
15476
  }
15477
+ this._openedPopup.splice(index, 1);
15478
+ }
15372
15479
  }
15373
- _getGeoJsonOptions(options, type) {
15374
- const paint = options.paint;
15375
- let lopt = {};
15376
- if (typeof paint === 'function') {
15377
- if (type === 'point') {
15378
- // TODO: fix types (@geoman-io/leaflet-geoman-free)
15379
- lopt.pointToLayer = (feature, latLng) => {
15380
- const iconOpt = paint(feature);
15381
- const pointToLayer = this._paint.createPaintToLayer(iconOpt);
15382
- return pointToLayer(feature, latLng);
15383
- };
15384
- }
15385
- else {
15386
- lopt = {
15387
- style: (feature) => {
15388
- if (feature) {
15389
- return this._paint.preparePaint({ ...PAINT, ...paint(feature) });
15390
- }
15391
- else {
15392
- return this._paint.preparePaint({ ...PAINT, type: 'path' });
15393
- }
15394
- },
15395
- };
15396
- }
15397
- }
15398
- else {
15399
- lopt = this._paint.createPaintOptions(paint);
15400
- }
15401
- lopt.onEachFeature = (feature, layer) => {
15402
- this._onEachFeature(feature, layer);
15480
+ }
15481
+ _getGeoJsonOptions(options, type) {
15482
+ const paint = options.paint;
15483
+ let lopt = {};
15484
+ if (typeof paint === "function") {
15485
+ if (type === "point") {
15486
+ lopt.pointToLayer = (feature, latLng) => {
15487
+ const iconOpt = paint(feature);
15488
+ const pointToLayer = this._paint.createPaintToLayer(
15489
+ iconOpt
15490
+ );
15491
+ return pointToLayer(feature, latLng);
15403
15492
  };
15404
- return lopt;
15405
- }
15406
- _onEachFeature(feature, layer) {
15407
- const layer_ = this.layer;
15408
- if (layer_) {
15409
- const def = {
15410
- target: this,
15411
- feature,
15412
- layer,
15413
- ...createFeaturePositionOptions(feature),
15414
- };
15415
- layer.options.pane = this.pane;
15416
- this._layers.push(def);
15417
- let ok = true;
15418
- if (this._filterFun) {
15419
- ok = this._filterFun(def);
15420
- }
15421
- if (ok) {
15422
- const { popup, popupOptions, selectable, interactive, selectOnHover } = this.options;
15423
- // @ts-ignore
15424
- layer.options.interactive = defined(interactive) ? interactive : true;
15425
- layer_.addLayer(layer);
15426
- if (selectable) {
15427
- if (selectOnHover) {
15428
- layer.on('mouseover', () => {
15429
- this._selectLayer(def, 'hover');
15430
- });
15431
- layer.on('mouseout', () => {
15432
- this._unSelectLayer(def);
15433
- });
15434
- }
15435
- else {
15436
- layer.on('click', (e) => this._selectOnLayerClick(e), this);
15437
- }
15438
- }
15439
- this._events.handleMouseEvents(layer);
15440
- // The timeout is needed to display the popup immediately when adding a layer to the map.
15441
- // Without a timeout, the layer may not yet have a _map object
15442
- setTimeout(() => {
15443
- if (popup) {
15444
- this._openPopup({
15445
- target: this,
15446
- layer,
15447
- feature,
15448
- ...createFeaturePositionOptions(feature),
15449
- }, popupOptions, 'api');
15450
- }
15451
- this._updateTooltip({ layer, feature });
15452
- });
15493
+ } else {
15494
+ lopt = {
15495
+ style: (feature) => {
15496
+ if (feature) {
15497
+ return this._paint.preparePaint(__spreadValues$5(__spreadValues$5({}, PAINT), paint(feature)));
15498
+ } else {
15499
+ return this._paint.preparePaint(__spreadProps$3(__spreadValues$5({}, PAINT), { type: "path" }));
15453
15500
  }
15454
- }
15455
- }
15456
- _selectOnLayerClick(e) {
15457
- leafletSrc.exports.DomEvent.stopPropagation(e);
15458
- const layer = e.target;
15459
- const feature = layer.feature;
15460
- const def = {
15461
- target: this,
15462
- layer,
15463
- feature,
15464
- ...createFeaturePositionOptions(feature),
15501
+ }
15465
15502
  };
15466
- const isSelected = this._getSelected(layer);
15467
- if (isSelected) {
15468
- if (this.options && this.options.unselectOnSecondClick) {
15469
- this._unSelectLayer(isSelected);
15470
- }
15471
- }
15472
- else {
15473
- this._selectLayer(def, 'click', e.latlng);
15474
- }
15503
+ }
15504
+ } else {
15505
+ lopt = this._paint.createPaintOptions(paint);
15475
15506
  }
15476
- _selectLayer(def, type, latlng) {
15477
- const { multiselect } = this.options;
15478
- if (!multiselect) {
15479
- // To unselect layer on another layer click
15480
- this.map._addUnselectCb(() => {
15481
- this._unSelectLayer(def);
15507
+ lopt.onEachFeature = (feature, layer) => {
15508
+ this._onEachFeature(feature, layer);
15509
+ };
15510
+ return lopt;
15511
+ }
15512
+ _onEachFeature(feature, layer) {
15513
+ const layer_ = this.layer;
15514
+ if (layer_) {
15515
+ const def = __spreadValues$5({
15516
+ target: this,
15517
+ feature,
15518
+ layer
15519
+ }, createFeaturePositionOptions(feature));
15520
+ layer.options.pane = this.pane;
15521
+ this._layers.push(def);
15522
+ let ok = true;
15523
+ if (this._filterFun) {
15524
+ ok = this._filterFun(def);
15525
+ }
15526
+ if (ok) {
15527
+ const { popup, popupOptions, selectable, interactive, selectOnHover } = this.options;
15528
+ layer.options.interactive = defined(interactive) ? interactive : true;
15529
+ layer_.addLayer(layer);
15530
+ if (selectable) {
15531
+ if (selectOnHover) {
15532
+ layer.on("mouseover", () => {
15533
+ this._selectLayer(def, "hover");
15482
15534
  });
15483
- this._selectedLayers.forEach((x) => this._unSelectLayer(x));
15484
- }
15485
- this._selectedLayers.push(def);
15486
- this.selected = true;
15487
- const { selectedPaint, popupOnSelect, popupOptions } = this.options;
15488
- if (selectedPaint && def.layer) {
15489
- this._paint.setPaint(def, selectedPaint);
15490
- }
15491
- if (popupOnSelect) {
15492
- this._openPopup(def, popupOptions, type, latlng);
15493
- }
15494
- if (this.options.onSelect) {
15495
- const features = def.feature ? [def.feature] : [];
15496
- this.options.onSelect({
15497
- type,
15498
- layer: this,
15499
- features,
15500
- ...createFeaturePositionOptions(features),
15535
+ layer.on("mouseout", () => {
15536
+ this._unSelectLayer(def);
15501
15537
  });
15538
+ } else {
15539
+ layer.on(
15540
+ "click",
15541
+ (e) => this._selectOnLayerClick(e),
15542
+ this
15543
+ );
15544
+ }
15502
15545
  }
15546
+ this._events.handleMouseEvents(layer);
15547
+ setTimeout(() => {
15548
+ if (popup) {
15549
+ this._openPopup(
15550
+ __spreadValues$5({
15551
+ target: this,
15552
+ layer,
15553
+ feature
15554
+ }, createFeaturePositionOptions(feature)),
15555
+ popupOptions,
15556
+ "api"
15557
+ );
15558
+ }
15559
+ this._updateTooltip({ layer, feature });
15560
+ });
15561
+ }
15503
15562
  }
15504
- _unSelectLayer(def) {
15505
- const index = this._selectedLayers.indexOf(def);
15506
- if (index !== -1) {
15507
- this._selectedLayers.splice(index, 1);
15508
- if (this.options) {
15509
- if (this.options.paint) {
15510
- this._paint.setPaint(def, this.options.paint);
15511
- }
15512
- if (this.options.popupOnSelect && def.layer) {
15513
- this._removePopup(def.layer);
15514
- }
15515
- }
15516
- }
15517
- this.selected = this._selectedLayers.length > 0;
15563
+ }
15564
+ _selectOnLayerClick(e) {
15565
+ leafletSrcExports.DomEvent.stopPropagation(e);
15566
+ const layer = e.target;
15567
+ const feature = layer.feature;
15568
+ const def = __spreadValues$5({
15569
+ target: this,
15570
+ layer,
15571
+ feature
15572
+ }, createFeaturePositionOptions(feature));
15573
+ const isSelected = this._getSelected(layer);
15574
+ if (isSelected) {
15575
+ if (this.options && this.options.unselectOnSecondClick) {
15576
+ this._unSelectLayer(isSelected);
15577
+ }
15578
+ } else {
15579
+ this._selectLayer(def, "click", e.latlng);
15518
15580
  }
15519
- _addMapClickListener() {
15520
- const map = this.map;
15521
- if (map) {
15522
- const { unselectOnClick } = this.options;
15523
- const uoc = unselectOnClick !== null && unselectOnClick !== void 0 ? unselectOnClick : true;
15524
- if (uoc) {
15525
- map.on('click', this.$unselect);
15526
- }
15527
- }
15581
+ }
15582
+ _selectLayer(def, type, latlng) {
15583
+ const { multiselect } = this.options;
15584
+ if (!multiselect) {
15585
+ this.map._addUnselectCb(() => {
15586
+ this._unSelectLayer(def);
15587
+ });
15588
+ this._selectedLayers.forEach((x) => this._unSelectLayer(x));
15528
15589
  }
15529
- _removeMapClickListener() {
15530
- this.map.off('zoomend', this.$updateTooltip);
15531
- this.map.off('moveend', this.$updateTooltip);
15532
- this.map.off('click', this.$unselect);
15590
+ this._selectedLayers.push(def);
15591
+ this.selected = true;
15592
+ const { selectedPaint, popupOnSelect, popupOptions } = this.options;
15593
+ if (selectedPaint && def.layer) {
15594
+ this._paint.setPaint(def, selectedPaint);
15533
15595
  }
15534
- _addMapListener() {
15535
- const map = this.map;
15536
- if (map) {
15537
- const { label, labelField, labelOnHover } = this.options;
15538
- this._addMapClickListener();
15539
- if ((labelField || label) && !labelOnHover) {
15540
- map.on('zoomend', this.$updateTooltip);
15541
- map.on('moveend', this.$updateTooltip);
15542
- }
15596
+ if (popupOnSelect) {
15597
+ this._openPopup(def, popupOptions, type, latlng);
15598
+ }
15599
+ if (this.options.onSelect) {
15600
+ const features = def.feature ? [def.feature] : [];
15601
+ this.options.onSelect(__spreadValues$5({
15602
+ type,
15603
+ layer: this,
15604
+ features
15605
+ }, createFeaturePositionOptions(features)));
15606
+ }
15607
+ }
15608
+ _unSelectLayer(def) {
15609
+ const index = this._selectedLayers.indexOf(def);
15610
+ if (index !== -1) {
15611
+ this._selectedLayers.splice(index, 1);
15612
+ if (this.options) {
15613
+ if (this.options.paint) {
15614
+ this._paint.setPaint(
15615
+ def,
15616
+ this.options.paint
15617
+ );
15543
15618
  }
15619
+ if (this.options.popupOnSelect && def.layer) {
15620
+ this._removePopup(def.layer);
15621
+ }
15622
+ }
15623
+ }
15624
+ this.selected = this._selectedLayers.length > 0;
15625
+ }
15626
+ _addMapClickListener() {
15627
+ const map = this.map;
15628
+ if (map) {
15629
+ const { unselectOnClick } = this.options;
15630
+ const uoc = unselectOnClick != null ? unselectOnClick : true;
15631
+ if (uoc) {
15632
+ map.on("click", this.$unselect);
15633
+ }
15544
15634
  }
15545
- _removeMapListener() {
15546
- this._removeMapClickListener();
15547
- this.map.off('zoomend', this.$updateTooltip);
15548
- this.map.off('moveend', this.$updateTooltip);
15635
+ }
15636
+ _removeMapClickListener() {
15637
+ this.map.off("zoomend", this.$updateTooltip);
15638
+ this.map.off("moveend", this.$updateTooltip);
15639
+ this.map.off("click", this.$unselect);
15640
+ }
15641
+ _addMapListener() {
15642
+ const map = this.map;
15643
+ if (map) {
15644
+ const { label, labelField, labelOnHover } = this.options;
15645
+ this._addMapClickListener();
15646
+ if ((labelField || label) && !labelOnHover) {
15647
+ map.on("zoomend", this.$updateTooltip);
15648
+ map.on("moveend", this.$updateTooltip);
15649
+ }
15549
15650
  }
15651
+ }
15652
+ _removeMapListener() {
15653
+ this._removeMapClickListener();
15654
+ this.map.off("zoomend", this.$updateTooltip);
15655
+ this.map.off("moveend", this.$updateTooltip);
15656
+ }
15550
15657
  }
15551
15658
 
15552
15659
  function callAjax(src, callback, headers) {
15553
- const xhr = new XMLHttpRequest();
15554
- xhr.open('GET', src);
15555
- xhr.responseType = 'arraybuffer';
15556
- for (const h in headers) {
15557
- xhr.setRequestHeader(h, headers[h]);
15558
- }
15559
- xhr.onload = function () {
15560
- const arrayBufferView = new Uint8Array(this.response);
15561
- const blob = new Blob([arrayBufferView], { type: 'image/png' });
15562
- // @ts-ignore for typedoc
15563
- const urlCreator = window.URL || window.webkitURL;
15564
- const imageUrl = urlCreator.createObjectURL(blob);
15565
- callback(imageUrl);
15566
- };
15567
- xhr.send();
15568
- return () => {
15569
- xhr.abort();
15570
- };
15660
+ const xhr = new XMLHttpRequest();
15661
+ xhr.open("GET", src);
15662
+ xhr.responseType = "arraybuffer";
15663
+ for (const h in headers) {
15664
+ xhr.setRequestHeader(h, headers[h]);
15665
+ }
15666
+ xhr.onload = function() {
15667
+ const arrayBufferView = new Uint8Array(this.response);
15668
+ const blob = new Blob([arrayBufferView], { type: "image/png" });
15669
+ const urlCreator = window.URL || window.webkitURL;
15670
+ const imageUrl = urlCreator.createObjectURL(blob);
15671
+ callback(imageUrl);
15672
+ };
15673
+ xhr.send();
15674
+ return () => {
15675
+ xhr.abort();
15676
+ };
15571
15677
  }
15572
15678
 
15573
- class ImageOverlay extends leafletSrc.exports.ImageOverlay {
15574
- constructor(imageUrl, bounds, options) {
15575
- super(imageUrl, bounds, options);
15576
- this._abort = [];
15577
- }
15578
- cancelLoad() {
15579
- if (this._abort) {
15580
- this._abort.forEach((x) => x());
15581
- this._abort = [];
15582
- }
15679
+ var __defProp$6 = Object.defineProperty;
15680
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15681
+ var __publicField$3 = (obj, key, value) => {
15682
+ __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
15683
+ return value;
15684
+ };
15685
+ class ImageOverlay extends leafletSrcExports.ImageOverlay {
15686
+ constructor(imageUrl, bounds, options) {
15687
+ super(imageUrl, bounds, options);
15688
+ __publicField$3(this, "_abort", []);
15689
+ }
15690
+ cancelLoad() {
15691
+ if (this._abort) {
15692
+ this._abort.forEach((x) => x());
15693
+ this._abort = [];
15583
15694
  }
15584
- _initImage() {
15585
- // @ts-ignore
15586
- super._initImage();
15587
- // @ts-ignore
15588
- const headers = this.options.headers;
15589
- if (headers) {
15590
- // @ts-ignore
15591
- const img = this._image;
15592
- const src = img.src;
15593
- img.src = '';
15594
- this._abort.push(callAjax(src, (response) => {
15595
- img.src = response;
15596
- }, headers));
15597
- }
15695
+ }
15696
+ _initImage() {
15697
+ super._initImage();
15698
+ const headers = this.options.headers;
15699
+ if (headers) {
15700
+ const img = this._image;
15701
+ const src = img.src;
15702
+ img.src = "";
15703
+ this._abort.push(
15704
+ callAjax(
15705
+ src,
15706
+ (response) => {
15707
+ img.src = response;
15708
+ },
15709
+ headers
15710
+ )
15711
+ );
15598
15712
  }
15713
+ }
15599
15714
  }
15600
15715
 
15601
- /*!
15602
- * leaflet.wms.js
15603
- * A collection of Leaflet utilities for working with Web Mapping services.
15604
- * (c) 2014-2016, Houston Engineering, Inc.
15605
- * MIT License
15606
- */
15607
- /*
15608
- * Overlay:
15609
- * "Single Tile" WMS image overlay that updates with map changes.
15610
- * Portions of wms.Overlay are directly extracted from L.TileLayer.WMS.
15611
- * See Leaflet license.
15612
- */
15613
- class ImageLayer extends leafletSrc.exports.Layer {
15614
- constructor(url, options) {
15615
- super(options);
15616
- this.defaultWmsParams = {
15617
- service: 'WMS',
15618
- request: 'GetMap',
15619
- version: '1.1.1',
15620
- layers: '',
15621
- styles: '',
15622
- format: 'image/jpeg',
15623
- transparent: false,
15624
- };
15625
- this.options = {
15626
- crs: null,
15627
- uppercase: false,
15628
- attribution: '',
15629
- opacity: 1,
15630
- isBack: false,
15631
- minZoom: 0,
15632
- pane: 'tilePane',
15633
- headers: null,
15634
- viewPortBuffer: 0,
15635
- setViewDelay: 100,
15636
- };
15637
- this._url = url;
15638
- // Move WMS parameters to params object
15639
- const params = {};
15640
- const opts = {};
15641
- let opt;
15642
- for (opt in options) {
15643
- if (opt in this.options) {
15644
- opts[opt] = options[opt];
15645
- }
15646
- else {
15647
- params[opt] = options[opt];
15648
- }
15649
- }
15650
- leafletSrc.exports.Util.setOptions(this, opts);
15651
- this.wmsParams = leafletSrc.exports.Util.extend({}, this.defaultWmsParams, params);
15716
+ var __defProp$5 = Object.defineProperty;
15717
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15718
+ var __publicField$2 = (obj, key, value) => {
15719
+ __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
15720
+ return value;
15721
+ };
15722
+ class ImageLayer extends leafletSrcExports.Layer {
15723
+ constructor(url, options) {
15724
+ super(options);
15725
+ __publicField$2(this, "defaultWmsParams", {
15726
+ service: "WMS",
15727
+ request: "GetMap",
15728
+ version: "1.1.1",
15729
+ layers: "",
15730
+ styles: "",
15731
+ format: "image/jpeg",
15732
+ transparent: false
15733
+ });
15734
+ __publicField$2(this, "options", {
15735
+ crs: null,
15736
+ uppercase: false,
15737
+ attribution: "",
15738
+ opacity: 1,
15739
+ isBack: false,
15740
+ minZoom: 0,
15741
+ pane: "tilePane",
15742
+ headers: null,
15743
+ viewPortBuffer: 0,
15744
+ setViewDelay: 100
15745
+ });
15746
+ __publicField$2(this, "wmsParams");
15747
+ __publicField$2(this, "_url");
15748
+ __publicField$2(this, "_currentUrl");
15749
+ __publicField$2(this, "_currentOverlay");
15750
+ this._url = url;
15751
+ const params = {};
15752
+ const opts = {};
15753
+ let opt;
15754
+ for (opt in options) {
15755
+ if (opt in this.options) {
15756
+ opts[opt] = options[opt];
15757
+ } else {
15758
+ params[opt] = options[opt];
15759
+ }
15652
15760
  }
15653
- setParams(params) {
15654
- leafletSrc.exports.Util.extend(this.wmsParams, params);
15655
- this.update();
15761
+ leafletSrcExports.Util.setOptions(this, opts);
15762
+ this.wmsParams = leafletSrcExports.Util.extend({}, this.defaultWmsParams, params);
15763
+ }
15764
+ setParams(params) {
15765
+ leafletSrcExports.Util.extend(this.wmsParams, params);
15766
+ this.update();
15767
+ }
15768
+ getAttribution() {
15769
+ return this.options.attribution || "";
15770
+ }
15771
+ onAdd() {
15772
+ this.update();
15773
+ return this;
15774
+ }
15775
+ onRemove(map) {
15776
+ if (this._currentOverlay) {
15777
+ this._currentOverlay.cancelLoad();
15778
+ map.removeLayer(this._currentOverlay);
15779
+ delete this._currentOverlay;
15656
15780
  }
15657
- getAttribution() {
15658
- return this.options.attribution || '';
15781
+ if (this._currentUrl) {
15782
+ delete this._currentUrl;
15659
15783
  }
15660
- onAdd() {
15661
- this.update();
15662
- return this;
15784
+ return this;
15785
+ }
15786
+ getEvents() {
15787
+ return {
15788
+ moveend: debounce(this.update, this.options.setViewDelay)
15789
+ };
15790
+ }
15791
+ update() {
15792
+ if (!this._map) {
15793
+ return;
15663
15794
  }
15664
- onRemove(map) {
15665
- if (this._currentOverlay) {
15666
- this._currentOverlay.cancelLoad();
15667
- map.removeLayer(this._currentOverlay);
15668
- delete this._currentOverlay;
15669
- }
15670
- if (this._currentUrl) {
15671
- delete this._currentUrl;
15672
- }
15673
- return this;
15795
+ this.updateWmsParams();
15796
+ const url = this.getImageUrl();
15797
+ if (this._currentUrl === url) {
15798
+ return;
15674
15799
  }
15675
- getEvents() {
15676
- return {
15677
- moveend: debounce(this.update, this.options.setViewDelay),
15678
- };
15800
+ this._currentUrl = url;
15801
+ const viewPortBuffer = this.options.viewPortBuffer || 0;
15802
+ const bounds = this._map.getBounds().pad(viewPortBuffer);
15803
+ const overlay = new ImageOverlay(url, bounds, {
15804
+ opacity: 0,
15805
+ pane: this.options.pane,
15806
+ headers: this.options.headers
15807
+ });
15808
+ overlay.addTo(this._map);
15809
+ if (this._currentOverlay) {
15810
+ this._currentOverlay.cancelLoad();
15679
15811
  }
15680
- update() {
15812
+ overlay.once(
15813
+ "load",
15814
+ () => {
15681
15815
  if (!this._map) {
15682
- return;
15816
+ return;
15683
15817
  }
15684
- // Determine image URL and whether it has changed since last update
15685
- this.updateWmsParams();
15686
- const url = this.getImageUrl();
15687
- if (this._currentUrl === url) {
15688
- return;
15818
+ if (overlay._url !== this._currentUrl) {
15819
+ this._map.removeLayer(overlay);
15820
+ return;
15821
+ } else if (this._currentOverlay) {
15822
+ this._map.removeLayer(this._currentOverlay);
15689
15823
  }
15690
- this._currentUrl = url;
15691
- // Keep current image overlay in place until new one loads
15692
- // (inspired by esri.leaflet)
15693
- const viewPortBuffer = this.options.viewPortBuffer || 0;
15694
- const bounds = this._map.getBounds().pad(viewPortBuffer);
15695
- const overlay = new ImageOverlay(url, bounds, {
15696
- opacity: 0,
15697
- pane: this.options.pane,
15698
- headers: this.options.headers,
15699
- });
15700
- overlay.addTo(this._map);
15701
- if (this._currentOverlay) {
15702
- this._currentOverlay.cancelLoad();
15824
+ this._currentOverlay = overlay;
15825
+ overlay.setOpacity(
15826
+ this.options.opacity !== void 0 ? this.options.opacity : 1
15827
+ );
15828
+ if (this.options.isBack === true) {
15829
+ overlay.bringToBack();
15703
15830
  }
15704
- overlay.once('load', () => {
15705
- if (!this._map) {
15706
- return;
15707
- }
15708
- // @ts-ignore
15709
- if (overlay._url !== this._currentUrl) {
15710
- this._map.removeLayer(overlay);
15711
- return;
15712
- }
15713
- else if (this._currentOverlay) {
15714
- this._map.removeLayer(this._currentOverlay);
15715
- }
15716
- this._currentOverlay = overlay;
15717
- overlay.setOpacity(this.options.opacity !== undefined ? this.options.opacity : 1);
15718
- if (this.options.isBack === true) {
15719
- overlay.bringToBack();
15720
- }
15721
- if (this.options.isBack === false) {
15722
- overlay.bringToFront();
15723
- }
15724
- if (this.options.zIndex !== undefined) {
15725
- overlay.setZIndex(this.options.zIndex);
15726
- }
15727
- }, this);
15728
- const { minZoom, maxZoom } = this.options;
15729
- if ((minZoom && this._map.getZoom() < minZoom) ||
15730
- (maxZoom && this._map.getZoom() > maxZoom)) {
15731
- this._map.removeLayer(overlay);
15831
+ if (this.options.isBack === false) {
15832
+ overlay.bringToFront();
15732
15833
  }
15733
- }
15734
- setOpacity(opacity) {
15735
- this.options.opacity = opacity;
15736
- if (this._currentOverlay) {
15737
- this._currentOverlay.setOpacity(opacity);
15834
+ if (this.options.zIndex !== void 0) {
15835
+ overlay.setZIndex(this.options.zIndex);
15738
15836
  }
15837
+ },
15838
+ this
15839
+ );
15840
+ const { minZoom, maxZoom } = this.options;
15841
+ if (minZoom && this._map.getZoom() < minZoom || maxZoom && this._map.getZoom() > maxZoom) {
15842
+ this._map.removeLayer(overlay);
15739
15843
  }
15740
- bringToBack() {
15741
- this.options.isBack = true;
15742
- if (this._currentOverlay) {
15743
- this._currentOverlay.bringToBack();
15744
- }
15844
+ }
15845
+ setOpacity(opacity) {
15846
+ this.options.opacity = opacity;
15847
+ if (this._currentOverlay) {
15848
+ this._currentOverlay.setOpacity(opacity);
15745
15849
  }
15746
- bringToFront() {
15747
- this.options.isBack = false;
15748
- if (this._currentOverlay) {
15749
- this._currentOverlay.bringToFront();
15750
- }
15850
+ }
15851
+ bringToBack() {
15852
+ this.options.isBack = true;
15853
+ if (this._currentOverlay) {
15854
+ this._currentOverlay.bringToBack();
15751
15855
  }
15752
- setZIndex(zIndex) {
15753
- this.options.zIndex = zIndex;
15754
- if (this._currentOverlay) {
15755
- this._currentOverlay.setZIndex(zIndex);
15756
- }
15856
+ }
15857
+ bringToFront() {
15858
+ this.options.isBack = false;
15859
+ if (this._currentOverlay) {
15860
+ this._currentOverlay.bringToFront();
15757
15861
  }
15758
- // See L.TileLayer.WMS: onAdd() & getTileUrl()
15759
- updateWmsParams(map) {
15760
- if (!map) {
15761
- map = this._map;
15762
- }
15763
- // Compute WMS options
15764
- const viewPortBuffer = this.options.viewPortBuffer || 0;
15765
- const bounds = map.getBounds().pad(viewPortBuffer);
15766
- const size = map.getSize();
15767
- if (this.options.viewPortBuffer !== 0) {
15768
- const factor = viewPortBuffer + 1;
15769
- size.x = Math.ceil(size.x * factor);
15770
- size.y = Math.ceil(size.y * factor);
15771
- }
15772
- const wmsVersion = parseFloat(this.wmsParams.version);
15773
- const crs = this.options.crs || map.options.crs;
15774
- const projectionKey = wmsVersion >= 1.3 ? 'crs' : 'srs';
15775
- if (crs) {
15776
- const nw = crs.project(bounds.getNorthWest());
15777
- const se = crs.project(bounds.getSouthEast());
15778
- // Assemble WMS parameter string
15779
- const params = {
15780
- width: size.x,
15781
- height: size.y,
15782
- };
15783
- params[projectionKey] = crs.code;
15784
- params.bbox = (wmsVersion >= 1.3 && crs === leafletSrc.exports.CRS.EPSG4326
15785
- ? [se.y, nw.x, nw.y, se.x]
15786
- : [nw.x, se.y, se.x, nw.y]).join(',');
15787
- leafletSrc.exports.Util.extend(this.wmsParams, params);
15788
- }
15862
+ }
15863
+ setZIndex(zIndex) {
15864
+ this.options.zIndex = zIndex;
15865
+ if (this._currentOverlay) {
15866
+ this._currentOverlay.setZIndex(zIndex);
15789
15867
  }
15790
- getImageUrl() {
15791
- const uppercase = this.options.uppercase || false;
15792
- const pstr = leafletSrc.exports.Util.getParamString(this.wmsParams, this._url, uppercase);
15793
- return this._url + pstr;
15868
+ }
15869
+ // See L.TileLayer.WMS: onAdd() & getTileUrl()
15870
+ updateWmsParams(map) {
15871
+ if (!map) {
15872
+ map = this._map;
15873
+ }
15874
+ const viewPortBuffer = this.options.viewPortBuffer || 0;
15875
+ const bounds = map.getBounds().pad(viewPortBuffer);
15876
+ const size = map.getSize();
15877
+ if (this.options.viewPortBuffer !== 0) {
15878
+ const factor = viewPortBuffer + 1;
15879
+ size.x = Math.ceil(size.x * factor);
15880
+ size.y = Math.ceil(size.y * factor);
15881
+ }
15882
+ const wmsVersion = parseFloat(this.wmsParams.version);
15883
+ const crs = this.options.crs || map.options.crs;
15884
+ const projectionKey = wmsVersion >= 1.3 ? "crs" : "srs";
15885
+ if (crs) {
15886
+ const nw = crs.project(bounds.getNorthWest());
15887
+ const se = crs.project(bounds.getSouthEast());
15888
+ const params = {
15889
+ width: size.x,
15890
+ height: size.y
15891
+ };
15892
+ params[projectionKey] = crs.code;
15893
+ params.bbox = (wmsVersion >= 1.3 && crs === leafletSrcExports.CRS.EPSG4326 ? [se.y, nw.x, nw.y, se.x] : [nw.x, se.y, se.x, nw.y]).join(",");
15894
+ leafletSrcExports.Util.extend(this.wmsParams, params);
15794
15895
  }
15896
+ }
15897
+ getImageUrl() {
15898
+ const uppercase = this.options.uppercase || false;
15899
+ const pstr = leafletSrcExports.Util.getParamString(this.wmsParams, this._url, uppercase);
15900
+ return this._url + pstr;
15901
+ }
15795
15902
  }
15796
15903
 
15904
+ var __defProp$4 = Object.defineProperty;
15905
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
15906
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
15907
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
15908
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15909
+ var __spreadValues$4 = (a, b) => {
15910
+ for (var prop in b || (b = {}))
15911
+ if (__hasOwnProp$4.call(b, prop))
15912
+ __defNormalProp$4(a, prop, b[prop]);
15913
+ if (__getOwnPropSymbols$4)
15914
+ for (var prop of __getOwnPropSymbols$4(b)) {
15915
+ if (__propIsEnum$4.call(b, prop))
15916
+ __defNormalProp$4(a, prop, b[prop]);
15917
+ }
15918
+ return a;
15919
+ };
15920
+ var __publicField$1 = (obj, key, value) => {
15921
+ __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
15922
+ return value;
15923
+ };
15797
15924
  class ImageAdapter extends BaseAdapter {
15798
- addLayer(options) {
15799
- const url = options && options.url;
15800
- if (url) {
15801
- options = { transparent: true, ...options };
15802
- const updateWmsParamsFromOpt = options.updateWmsParams;
15803
- this.layer = new ImageLayer(url, {
15804
- pane: this.pane,
15805
- headers: options.headers,
15806
- setViewDelay: options.setViewDelay,
15807
- /**
15808
- * TODO: safe remove, use only options.nativeOptions
15809
- */
15810
- ...options,
15811
- ...options.params,
15812
- ...options.nativeOptions,
15813
- });
15814
- if (updateWmsParamsFromOpt) {
15815
- const updateWmsParams = this.layer.updateWmsParams;
15816
- this.layer.updateWmsParams = function (map) {
15817
- updateWmsParams.call(this, map);
15818
- this.wmsParams = updateWmsParamsFromOpt(this.wmsParams);
15819
- };
15820
- }
15821
- return this.layer;
15822
- }
15925
+ constructor() {
15926
+ super(...arguments);
15927
+ __publicField$1(this, "layer");
15928
+ }
15929
+ addLayer(options) {
15930
+ const url = options && options.url;
15931
+ if (url) {
15932
+ options = __spreadValues$4({ transparent: true }, options);
15933
+ const updateWmsParamsFromOpt = options.updateWmsParams;
15934
+ this.layer = new ImageLayer(url, __spreadValues$4(__spreadValues$4(__spreadValues$4({
15935
+ pane: this.pane,
15936
+ headers: options.headers,
15937
+ setViewDelay: options.setViewDelay
15938
+ }, options), options.params), options.nativeOptions));
15939
+ if (updateWmsParamsFromOpt) {
15940
+ const updateWmsParams = this.layer.updateWmsParams;
15941
+ this.layer.updateWmsParams = function(map) {
15942
+ updateWmsParams.call(this, map);
15943
+ this.wmsParams = updateWmsParamsFromOpt(this.wmsParams);
15944
+ };
15945
+ }
15946
+ return this.layer;
15823
15947
  }
15948
+ }
15824
15949
  }
15825
15950
 
15826
15951
  function makeRemote(Base) {
15827
- return class RemoteTileLayer extends Base {
15828
- constructor(...args) {
15829
- super(...args);
15830
- if (this.options.setViewDelay) {
15831
- // @ts-ignore
15832
- this._update = debounce((...a) => {
15833
- // @ts-ignore
15834
- leafletSrc.exports.GridLayer.prototype._update.call(this, ...a);
15835
- }, this.options.setViewDelay);
15836
- }
15837
- }
15838
- createTile(coords, done) {
15839
- // @ts-ignore
15840
- const url = this.getTileUrl(coords);
15841
- const tile = document.createElement('img');
15842
- tile.abort = callAjax(url, (response) => {
15843
- tile.src = response;
15844
- done(null, tile);
15845
- },
15846
- // @ts-ignore
15847
- this.options.headers);
15848
- if (this.options.crossOrigin || this.options.crossOrigin === '') {
15849
- tile.crossOrigin =
15850
- this.options.crossOrigin === true ? '' : this.options.crossOrigin;
15851
- }
15852
- tile.alt = '';
15853
- tile.setAttribute('role', 'presentation');
15854
- return tile;
15855
- }
15856
- _abortLoading() {
15857
- // @ts-ignore
15858
- const tiles = this._tiles;
15859
- // @ts-ignore
15860
- const tileZoom = this._tileZoom;
15861
- for (const i in tiles) {
15862
- if (tiles[i].coords.z !== tileZoom) {
15863
- const tile = tiles[i].el;
15864
- tile.onload = leafletSrc.exports.Util.falseFn;
15865
- tile.onerror = leafletSrc.exports.Util.falseFn;
15866
- if (!tile.complete) {
15867
- if (tile.abort) {
15868
- tile.abort();
15869
- }
15870
- tile.src = leafletSrc.exports.Util.emptyImageUrl;
15871
- leafletSrc.exports.DomUtil.remove(tile);
15872
- delete tiles[i];
15873
- }
15874
- }
15952
+ return class RemoteTileLayer extends Base {
15953
+ constructor(...args) {
15954
+ super(...args);
15955
+ if (this.options.setViewDelay) {
15956
+ this._update = debounce((...a) => {
15957
+ leafletSrcExports.GridLayer.prototype._update.call(this, ...a);
15958
+ }, this.options.setViewDelay);
15959
+ }
15960
+ }
15961
+ createTile(coords, done) {
15962
+ const url = this.getTileUrl(coords);
15963
+ const tile = document.createElement("img");
15964
+ tile.abort = callAjax(
15965
+ url,
15966
+ (response) => {
15967
+ tile.src = response;
15968
+ done(null, tile);
15969
+ },
15970
+ // @ts-ignore
15971
+ this.options.headers
15972
+ );
15973
+ if (this.options.crossOrigin || this.options.crossOrigin === "") {
15974
+ tile.crossOrigin = this.options.crossOrigin === true ? "" : this.options.crossOrigin;
15975
+ }
15976
+ tile.alt = "";
15977
+ tile.setAttribute("role", "presentation");
15978
+ return tile;
15979
+ }
15980
+ _abortLoading() {
15981
+ const tiles = this._tiles;
15982
+ const tileZoom = this._tileZoom;
15983
+ for (const i in tiles) {
15984
+ if (tiles[i].coords.z !== tileZoom) {
15985
+ const tile = tiles[i].el;
15986
+ tile.onload = leafletSrcExports.Util.falseFn;
15987
+ tile.onerror = leafletSrcExports.Util.falseFn;
15988
+ if (!tile.complete) {
15989
+ if (tile.abort) {
15990
+ tile.abort();
15875
15991
  }
15992
+ tile.src = leafletSrcExports.Util.emptyImageUrl;
15993
+ leafletSrcExports.DomUtil.remove(tile);
15994
+ delete tiles[i];
15995
+ }
15876
15996
  }
15877
- };
15997
+ }
15998
+ }
15999
+ };
15878
16000
  }
15879
16001
 
15880
- class TileLayerBase extends leafletSrc.exports.TileLayer {
15881
- constructor(urlTemplate, options) {
15882
- super(urlTemplate, options);
15883
- Object.assign(this.options, options);
15884
- }
16002
+ class TileLayerBase extends leafletSrcExports.TileLayer {
16003
+ constructor(urlTemplate, options) {
16004
+ super(urlTemplate, options);
16005
+ Object.assign(this.options, options);
16006
+ }
15885
16007
  }
15886
16008
  const TileLayer = makeRemote(TileLayerBase);
15887
16009
 
16010
+ var __defProp$3 = Object.defineProperty;
16011
+ var __defProps$2 = Object.defineProperties;
16012
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
16013
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
16014
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
16015
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
16016
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
16017
+ var __spreadValues$3 = (a, b) => {
16018
+ for (var prop in b || (b = {}))
16019
+ if (__hasOwnProp$3.call(b, prop))
16020
+ __defNormalProp$3(a, prop, b[prop]);
16021
+ if (__getOwnPropSymbols$3)
16022
+ for (var prop of __getOwnPropSymbols$3(b)) {
16023
+ if (__propIsEnum$3.call(b, prop))
16024
+ __defNormalProp$3(a, prop, b[prop]);
16025
+ }
16026
+ return a;
16027
+ };
16028
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
16029
+ var __objRest$1 = (source, exclude) => {
16030
+ var target = {};
16031
+ for (var prop in source)
16032
+ if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
16033
+ target[prop] = source[prop];
16034
+ if (source != null && __getOwnPropSymbols$3)
16035
+ for (var prop of __getOwnPropSymbols$3(source)) {
16036
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
16037
+ target[prop] = source[prop];
16038
+ }
16039
+ return target;
16040
+ };
15888
16041
  class TileAdapter extends BaseAdapter {
15889
- addLayer(options) {
15890
- this.options = Object.assign(this.options, options);
15891
- if (options) {
15892
- const { url, ...opt } = options;
15893
- if (url) {
15894
- const tileLayerOptions = {
15895
- pane: this.pane,
15896
- attribution: opt.attribution,
15897
- minZoom: opt.minZoom,
15898
- maxZoom: opt.maxZoom,
15899
- ...opt.nativeOptions,
15900
- };
15901
- if (opt.subdomains) {
15902
- tileLayerOptions.subdomains = opt.subdomains;
15903
- }
15904
- let layer;
15905
- if (opt.headers) {
15906
- layer = new TileLayer(url, {
15907
- ...tileLayerOptions,
15908
- headers: opt.headers,
15909
- setViewDelay: opt.setViewDelay,
15910
- });
15911
- }
15912
- else {
15913
- layer = new leafletSrc.exports.TileLayer(url, tileLayerOptions);
15914
- }
15915
- return layer;
15916
- }
16042
+ addLayer(options) {
16043
+ this.options = Object.assign(this.options, options);
16044
+ if (options) {
16045
+ const _a = options, { url } = _a, opt = __objRest$1(_a, ["url"]);
16046
+ if (url) {
16047
+ const tileLayerOptions = __spreadValues$3({
16048
+ pane: this.pane,
16049
+ attribution: opt.attribution,
16050
+ minZoom: opt.minZoom,
16051
+ maxZoom: opt.maxZoom
16052
+ }, opt.nativeOptions);
16053
+ if (opt.subdomains) {
16054
+ tileLayerOptions.subdomains = opt.subdomains;
16055
+ }
16056
+ let layer;
16057
+ if (opt.headers) {
16058
+ layer = new TileLayer(url, __spreadProps$2(__spreadValues$3({}, tileLayerOptions), {
16059
+ headers: opt.headers,
16060
+ setViewDelay: opt.setViewDelay
16061
+ }));
16062
+ } else {
16063
+ layer = new leafletSrcExports.TileLayer(url, tileLayerOptions);
15917
16064
  }
16065
+ return layer;
16066
+ }
15918
16067
  }
16068
+ }
15919
16069
  }
15920
16070
 
15921
- class OsmAdapter extends TileAdapter {
15922
- addLayer(options) {
15923
- const url = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
15924
- return super.addLayer({
15925
- name: 'OpenStreetMap',
15926
- attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
15927
- ...options,
15928
- url,
15929
- });
16071
+ var __defProp$2 = Object.defineProperty;
16072
+ var __defProps$1 = Object.defineProperties;
16073
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
16074
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
16075
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
16076
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
16077
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
16078
+ var __spreadValues$2 = (a, b) => {
16079
+ for (var prop in b || (b = {}))
16080
+ if (__hasOwnProp$2.call(b, prop))
16081
+ __defNormalProp$2(a, prop, b[prop]);
16082
+ if (__getOwnPropSymbols$2)
16083
+ for (var prop of __getOwnPropSymbols$2(b)) {
16084
+ if (__propIsEnum$2.call(b, prop))
16085
+ __defNormalProp$2(a, prop, b[prop]);
15930
16086
  }
16087
+ return a;
16088
+ };
16089
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
16090
+ class OsmAdapter extends TileAdapter {
16091
+ addLayer(options) {
16092
+ const url = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png";
16093
+ return super.addLayer(__spreadProps$1(__spreadValues$2({
16094
+ name: "OpenStreetMap",
16095
+ attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
16096
+ }, options), {
16097
+ url
16098
+ }));
16099
+ }
15931
16100
  }
15932
16101
 
15933
- class WmsLayerBase extends leafletSrc.exports.TileLayer.WMS {
15934
- constructor(urlTemplate, options) {
15935
- super(urlTemplate, options);
15936
- }
16102
+ class WmsLayerBase extends leafletSrcExports.TileLayer.WMS {
16103
+ constructor(urlTemplate, options) {
16104
+ super(urlTemplate, options);
16105
+ }
15937
16106
  }
15938
16107
  const WmsLayer = makeRemote(WmsLayerBase);
15939
16108
 
16109
+ var __defProp$1 = Object.defineProperty;
16110
+ var __defProps = Object.defineProperties;
16111
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
16112
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
16113
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
16114
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
16115
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
16116
+ var __spreadValues$1 = (a, b) => {
16117
+ for (var prop in b || (b = {}))
16118
+ if (__hasOwnProp$1.call(b, prop))
16119
+ __defNormalProp$1(a, prop, b[prop]);
16120
+ if (__getOwnPropSymbols$1)
16121
+ for (var prop of __getOwnPropSymbols$1(b)) {
16122
+ if (__propIsEnum$1.call(b, prop))
16123
+ __defNormalProp$1(a, prop, b[prop]);
16124
+ }
16125
+ return a;
16126
+ };
16127
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
16128
+ var __objRest = (source, exclude) => {
16129
+ var target = {};
16130
+ for (var prop in source)
16131
+ if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
16132
+ target[prop] = source[prop];
16133
+ if (source != null && __getOwnPropSymbols$1)
16134
+ for (var prop of __getOwnPropSymbols$1(source)) {
16135
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
16136
+ target[prop] = source[prop];
16137
+ }
16138
+ return target;
16139
+ };
15940
16140
  class WmsAdapter extends BaseAdapter {
15941
- addLayer(options) {
15942
- Object.assign(this.options, options);
15943
- const { url, ...opt } = options;
15944
- if (url) {
15945
- const layerOptions = {
15946
- pane: this.pane,
15947
- attribution: opt.attribution,
15948
- minZoom: opt.minZoom,
15949
- maxZoom: opt.maxZoom,
15950
- layers: options.layers,
15951
- format: options.format,
15952
- ...options.nativeOptions,
15953
- };
15954
- let layer;
15955
- if (opt.headers) {
15956
- layer = new WmsLayer(url, { ...layerOptions, headers: opt.headers });
15957
- }
15958
- else {
15959
- layer = new leafletSrc.exports.TileLayer.WMS(url, layerOptions);
15960
- }
15961
- return layer;
15962
- }
16141
+ addLayer(options) {
16142
+ Object.assign(this.options, options);
16143
+ const _a = options, { url } = _a, opt = __objRest(_a, ["url"]);
16144
+ if (url) {
16145
+ const layerOptions = __spreadValues$1({
16146
+ pane: this.pane,
16147
+ attribution: opt.attribution,
16148
+ minZoom: opt.minZoom,
16149
+ maxZoom: opt.maxZoom,
16150
+ layers: options.layers,
16151
+ format: options.format
16152
+ }, options.nativeOptions);
16153
+ let layer;
16154
+ if (opt.headers) {
16155
+ layer = new WmsLayer(url, __spreadProps(__spreadValues$1({}, layerOptions), { headers: opt.headers }));
16156
+ } else {
16157
+ layer = new leafletSrcExports.TileLayer.WMS(url, layerOptions);
16158
+ }
16159
+ return layer;
15963
16160
  }
16161
+ }
15964
16162
  }
15965
16163
 
15966
16164
  function arrayToBoundsExpression(bounds) {
15967
- const e = bounds;
15968
- // top, left, bottom, right
15969
- return [
15970
- [e[3], e[0]],
15971
- [e[1], e[2]],
15972
- ];
16165
+ const e = bounds;
16166
+ return [
16167
+ [e[3], e[0]],
16168
+ [e[1], e[2]]
16169
+ ];
15973
16170
  }
15974
16171
 
15975
- class LeafletMapAdapter$1 {
15976
- constructor() {
15977
- this.options = { target: 'map' };
15978
- this.layerAdapters = LeafletMapAdapter$1.layerAdapters;
15979
- this.controlAdapters = LeafletMapAdapter$1.controlAdapters;
15980
- this.emitter = new events.exports.EventEmitter();
15981
- this._unselectCb = [];
15982
- this._universalEvents = [
15983
- 'move',
15984
- 'zoom',
15985
- 'zoomend',
15986
- 'zoomstart',
15987
- 'moveend',
15988
- 'movestart',
15989
- ];
15990
- this._positionEvents = [
15991
- 'mousemove',
15992
- 'mouseout',
15993
- 'mouseover',
15994
- ];
15995
- }
15996
- create(options) {
15997
- this.options = { ...options };
15998
- if (this.options.target) {
15999
- const { zoom, center, maxZoom, minZoom, maxBounds: mb, mapAdapterOptions, } = this.options;
16000
- this.map =
16001
- this.options.map ||
16002
- new leafletSrc.exports.Map(this.options.target, {
16003
- attributionControl: false,
16004
- zoomControl: false,
16005
- maxBounds: mb ? arrayToBoundsExpression(mb) : undefined,
16006
- maxZoom,
16007
- minZoom,
16008
- center: center && [center[1], center[0]],
16009
- zoom,
16010
- ...mapAdapterOptions,
16011
- });
16012
- // create default pane
16013
- const defPane = this.map.createPane('order-0');
16014
- this.map._addUnselectCb = (def) => {
16015
- this._addUnselectCb(def);
16016
- };
16017
- defPane.style.zIndex = String(0);
16018
- this.emitter.emit('create', this);
16019
- this._addMapListeners();
16020
- }
16172
+ var __defProp = Object.defineProperty;
16173
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
16174
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16175
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
16176
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
16177
+ var __spreadValues = (a, b) => {
16178
+ for (var prop in b || (b = {}))
16179
+ if (__hasOwnProp.call(b, prop))
16180
+ __defNormalProp(a, prop, b[prop]);
16181
+ if (__getOwnPropSymbols)
16182
+ for (var prop of __getOwnPropSymbols(b)) {
16183
+ if (__propIsEnum.call(b, prop))
16184
+ __defNormalProp(a, prop, b[prop]);
16021
16185
  }
16022
- destroy() {
16023
- if (this.map) {
16024
- this.map.remove();
16025
- }
16026
- this._stopWatchSizeChangeToUpdateMinZoom();
16186
+ return a;
16187
+ };
16188
+ var __publicField = (obj, key, value) => {
16189
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
16190
+ return value;
16191
+ };
16192
+ const _LeafletMapAdapter = class _LeafletMapAdapter {
16193
+ constructor() {
16194
+ __publicField(this, "options", { target: "map" });
16195
+ __publicField(this, "layerAdapters", _LeafletMapAdapter.layerAdapters);
16196
+ __publicField(this, "controlAdapters", _LeafletMapAdapter.controlAdapters);
16197
+ __publicField(this, "emitter", new EventEmitter());
16198
+ __publicField(this, "map");
16199
+ __publicField(this, "_resizeObserver");
16200
+ __publicField(this, "_unselectCb", []);
16201
+ __publicField(this, "_universalEvents", [
16202
+ "move",
16203
+ "zoom",
16204
+ "zoomend",
16205
+ "zoomstart",
16206
+ "moveend",
16207
+ "movestart"
16208
+ ]);
16209
+ __publicField(this, "_positionEvents", [
16210
+ "mousemove",
16211
+ "mouseout",
16212
+ "mouseover"
16213
+ ]);
16214
+ }
16215
+ create(options) {
16216
+ this.options = __spreadValues({}, options);
16217
+ if (this.options.target) {
16218
+ const {
16219
+ zoom,
16220
+ center,
16221
+ maxZoom,
16222
+ minZoom,
16223
+ maxBounds: mb,
16224
+ mapAdapterOptions
16225
+ } = this.options;
16226
+ this.map = this.options.map || new leafletSrcExports.Map(this.options.target, __spreadValues({
16227
+ attributionControl: false,
16228
+ zoomControl: false,
16229
+ maxBounds: mb ? arrayToBoundsExpression(mb) : void 0,
16230
+ maxZoom,
16231
+ minZoom,
16232
+ center: center && [center[1], center[0]],
16233
+ zoom
16234
+ }, mapAdapterOptions));
16235
+ const defPane = this.map.createPane("order-0");
16236
+ this.map._addUnselectCb = (def) => {
16237
+ this._addUnselectCb(def);
16238
+ };
16239
+ defPane.style.zIndex = String(0);
16240
+ this.emitter.emit("create", this);
16241
+ this._addMapListeners();
16027
16242
  }
16028
- getContainer() {
16029
- return this.map && this.map.getContainer();
16243
+ }
16244
+ destroy() {
16245
+ if (this.map) {
16246
+ this.map.remove();
16030
16247
  }
16031
- getControlContainer() {
16032
- const controlContainer = this.map && this.map._controlContainer;
16033
- if (controlContainer) {
16034
- return controlContainer;
16035
- }
16036
- throw new Error('Leaflet Map is not initialized yet');
16248
+ this._stopWatchSizeChangeToUpdateMinZoom();
16249
+ }
16250
+ getContainer() {
16251
+ return this.map && this.map.getContainer();
16252
+ }
16253
+ getControlContainer() {
16254
+ const controlContainer = this.map && this.map._controlContainer;
16255
+ if (controlContainer) {
16256
+ return controlContainer;
16037
16257
  }
16038
- setCursor(cursor) {
16039
- if (this.map) {
16040
- this.map.getContainer().style.cursor = cursor;
16041
- }
16258
+ throw new Error("Leaflet Map is not initialized yet");
16259
+ }
16260
+ setCursor(cursor) {
16261
+ if (this.map) {
16262
+ this.map.getContainer().style.cursor = cursor;
16042
16263
  }
16043
- setView(lngLatOrOpt, zoom) {
16044
- const map = this.map;
16045
- if (!map)
16046
- return;
16047
- if (Array.isArray(lngLatOrOpt)) {
16048
- const lngLat = lngLatOrOpt;
16049
- const [lng, lat] = lngLat;
16050
- if (this.map) {
16051
- if (typeof zoom === 'number') {
16052
- this.map.setView([lat, lng], zoom, { animate: false });
16053
- }
16054
- else {
16055
- this.setCenter([lng, lat]);
16056
- }
16057
- }
16058
- }
16059
- else {
16060
- const { zoom, center, maxBounds, bounds, minZoom, maxZoom } = lngLatOrOpt;
16061
- if (center && zoom !== undefined) {
16062
- this.setView(center, zoom);
16063
- }
16064
- else {
16065
- if (zoom !== undefined) {
16066
- this.setZoom(zoom);
16067
- }
16068
- if (center) {
16069
- this.setCenter(center);
16070
- }
16071
- }
16072
- if (bounds) {
16073
- this.fitBounds(bounds);
16074
- }
16075
- if (maxBounds !== undefined) {
16076
- if (maxBounds) {
16077
- const b = arrayToBoundsExpression(maxBounds);
16078
- map.setMaxBounds(b);
16079
- map.setMinZoom(map.getBoundsZoom(b));
16080
- this._watchSizeChangeToUpdateMinZoom(b);
16081
- }
16082
- else {
16083
- // @ts-ignore `null` works for unset maxBounds, but not in typing
16084
- map.setMaxBounds(null);
16085
- this._stopWatchSizeChangeToUpdateMinZoom();
16086
- }
16087
- }
16088
- if (maxZoom !== undefined) {
16089
- map.setMaxZoom(maxZoom);
16090
- }
16091
- if (minZoom !== undefined) {
16092
- this._stopWatchSizeChangeToUpdateMinZoom();
16093
- map.setMinZoom(minZoom);
16094
- }
16264
+ }
16265
+ setView(lngLatOrOpt, zoom) {
16266
+ const map = this.map;
16267
+ if (!map)
16268
+ return;
16269
+ if (Array.isArray(lngLatOrOpt)) {
16270
+ const lngLat = lngLatOrOpt;
16271
+ const [lng, lat] = lngLat;
16272
+ if (this.map) {
16273
+ if (typeof zoom === "number") {
16274
+ this.map.setView([lat, lng], zoom, { animate: false });
16275
+ } else {
16276
+ this.setCenter([lng, lat]);
16095
16277
  }
16096
- }
16097
- setCenter(lngLat) {
16098
- const [lng, lat] = lngLat;
16099
- if (this.map) {
16100
- this.map.panTo([lat, lng]);
16278
+ }
16279
+ } else {
16280
+ const { zoom: zoom2, center, maxBounds, bounds, minZoom, maxZoom } = lngLatOrOpt;
16281
+ if (center && zoom2 !== void 0) {
16282
+ this.setView(center, zoom2);
16283
+ } else {
16284
+ if (zoom2 !== void 0) {
16285
+ this.setZoom(zoom2);
16101
16286
  }
16102
- }
16103
- getCenter() {
16104
- const map = this.map;
16105
- if (map) {
16106
- const bounds = map.getBounds();
16107
- const center = bounds.getCenter();
16108
- return [center.lng, center.lat];
16287
+ if (center) {
16288
+ this.setCenter(center);
16109
16289
  }
16110
- }
16111
- setZoom(zoom) {
16112
- if (this.map) {
16113
- this.map.setZoom(zoom);
16290
+ }
16291
+ if (bounds) {
16292
+ this.fitBounds(bounds);
16293
+ }
16294
+ if (maxBounds !== void 0) {
16295
+ if (maxBounds) {
16296
+ const b = arrayToBoundsExpression(maxBounds);
16297
+ map.setMaxBounds(b);
16298
+ map.setMinZoom(map.getBoundsZoom(b));
16299
+ this._watchSizeChangeToUpdateMinZoom(b);
16300
+ } else {
16301
+ map.setMaxBounds(null);
16302
+ this._stopWatchSizeChangeToUpdateMinZoom();
16114
16303
  }
16304
+ }
16305
+ if (maxZoom !== void 0) {
16306
+ map.setMaxZoom(maxZoom);
16307
+ }
16308
+ if (minZoom !== void 0) {
16309
+ this._stopWatchSizeChangeToUpdateMinZoom();
16310
+ map.setMinZoom(minZoom);
16311
+ }
16115
16312
  }
16116
- getZoom() {
16117
- var _a;
16118
- return (_a = (this.map && this.map.getZoom())) !== null && _a !== void 0 ? _a : undefined;
16119
- }
16120
- getBounds() {
16121
- if (!this.map)
16122
- return undefined;
16123
- const b = this.map.getBounds();
16124
- const sw = b.getSouthWest();
16125
- const ne = b.getNorthEast();
16126
- return [sw.lng, sw.lat, ne.lng, ne.lat];
16313
+ }
16314
+ setCenter(lngLat) {
16315
+ const [lng, lat] = lngLat;
16316
+ if (this.map) {
16317
+ this.map.panTo([lat, lng]);
16127
16318
  }
16128
- // [west, south, east, north]
16129
- fitBounds(bounds, options = {}) {
16130
- if (this.map) {
16131
- const { maxZoom, offset, padding } = options;
16132
- const opt = {};
16133
- if (maxZoom) {
16134
- opt.maxZoom = maxZoom;
16135
- }
16136
- if (padding) {
16137
- opt.padding = [padding, padding];
16138
- }
16139
- if (offset) {
16140
- opt.padding = offset;
16141
- }
16142
- this.map.fitBounds(arrayToBoundsExpression(bounds), opt);
16143
- }
16319
+ }
16320
+ getCenter() {
16321
+ const map = this.map;
16322
+ if (map) {
16323
+ const bounds = map.getBounds();
16324
+ const center = bounds.getCenter();
16325
+ return [center.lng, center.lat];
16144
16326
  }
16145
- getLayerAdapter(name) {
16146
- return LeafletMapAdapter$1.layerAdapters[name];
16327
+ }
16328
+ setZoom(zoom) {
16329
+ if (this.map) {
16330
+ this.map.setZoom(zoom);
16147
16331
  }
16148
- createControl(control, options) {
16149
- return createControl(control, options, this);
16332
+ }
16333
+ getZoom() {
16334
+ var _a;
16335
+ return (_a = this.map && this.map.getZoom()) != null ? _a : void 0;
16336
+ }
16337
+ getBounds() {
16338
+ if (!this.map)
16339
+ return void 0;
16340
+ const b = this.map.getBounds();
16341
+ const sw = b.getSouthWest();
16342
+ const ne = b.getNorthEast();
16343
+ return [sw.lng, sw.lat, ne.lng, ne.lat];
16344
+ }
16345
+ // [west, south, east, north]
16346
+ fitBounds(bounds, options = {}) {
16347
+ if (this.map) {
16348
+ const { maxZoom, offset, padding } = options;
16349
+ const opt = {};
16350
+ if (maxZoom) {
16351
+ opt.maxZoom = maxZoom;
16352
+ }
16353
+ if (padding) {
16354
+ opt.padding = [padding, padding];
16355
+ }
16356
+ if (offset) {
16357
+ opt.padding = offset;
16358
+ }
16359
+ this.map.fitBounds(arrayToBoundsExpression(bounds), opt);
16150
16360
  }
16151
- createButtonControl(options) {
16152
- return createButtonControl(options, this);
16361
+ }
16362
+ getLayerAdapter(name) {
16363
+ return _LeafletMapAdapter.layerAdapters[name];
16364
+ }
16365
+ createControl(control, options) {
16366
+ return createControl(control, options, this);
16367
+ }
16368
+ createButtonControl(options) {
16369
+ return createButtonControl(options, this);
16370
+ }
16371
+ addControl(control, position) {
16372
+ control.options.position = position.replace("-", "");
16373
+ if (this.map) {
16374
+ this.map.addControl(control);
16375
+ return control;
16153
16376
  }
16154
- addControl(control, position) {
16155
- control.options.position = position.replace('-', '');
16156
- if (this.map) {
16157
- this.map.addControl(control);
16158
- return control;
16159
- }
16377
+ }
16378
+ removeControl(control) {
16379
+ if (this.map) {
16380
+ this.map.removeControl(control);
16160
16381
  }
16161
- removeControl(control) {
16162
- if (this.map) {
16163
- this.map.removeControl(control);
16164
- }
16382
+ }
16383
+ removeLayer(layer) {
16384
+ layer && layer.remove && layer.remove();
16385
+ }
16386
+ showLayer(layer) {
16387
+ if (this.map) {
16388
+ layer.addTo(this.map);
16165
16389
  }
16166
- removeLayer(layer) {
16167
- layer && layer.remove && layer.remove();
16390
+ }
16391
+ hideLayer(layer) {
16392
+ layer.remove();
16393
+ }
16394
+ setLayerOpacity(layer, value) {
16395
+ if ("setOpacity" in layer) {
16396
+ layer.setOpacity(value);
16168
16397
  }
16169
- showLayer(layer) {
16170
- if (this.map) {
16171
- layer.addTo(this.map);
16398
+ }
16399
+ setLayerOrder(layer, order, layers) {
16400
+ }
16401
+ onMapClick(evt) {
16402
+ const converted = convertMapClickEvent(evt);
16403
+ this.emitter.emit("preclick", converted);
16404
+ this.emitter.emit("click", converted);
16405
+ }
16406
+ locate(opt, events) {
16407
+ const map = this.map;
16408
+ if (map) {
16409
+ map.locate(opt);
16410
+ if (events) {
16411
+ const { locationfound, locationerror } = events;
16412
+ const locationFound = (e) => {
16413
+ const event = e;
16414
+ const lngLat = [event.latlng.lng, event.latlng.lat];
16415
+ locationfound({ lngLat });
16416
+ };
16417
+ if (locationfound !== void 0) {
16418
+ map.on("locationfound", locationFound, this);
16172
16419
  }
16173
- }
16174
- hideLayer(layer) {
16175
- layer.remove();
16176
- }
16177
- setLayerOpacity(layer, value) {
16178
- if ('setOpacity' in layer) {
16179
- layer.setOpacity(value);
16420
+ if (locationerror) {
16421
+ map.on("locationerror", locationerror, this);
16180
16422
  }
16423
+ const stop2 = () => {
16424
+ if (locationfound !== void 0) {
16425
+ map.off("locationfound", locationFound);
16426
+ }
16427
+ if (locationerror) {
16428
+ map.off("locationerror", locationerror);
16429
+ }
16430
+ };
16431
+ return { stop: stop2 };
16432
+ }
16181
16433
  }
16182
- setLayerOrder(layer, order, layers) {
16183
- //
16184
- }
16185
- onMapClick(evt) {
16186
- const converted = convertMapClickEvent(evt);
16187
- this.emitter.emit('preclick', converted);
16188
- this.emitter.emit('click', converted);
16189
- }
16190
- locate(opt, events) {
16191
- const map = this.map;
16192
- if (map) {
16193
- map.locate(opt);
16194
- if (events) {
16195
- const { locationfound, locationerror } = events;
16196
- const locationFound = (e) => {
16197
- const event = e;
16198
- const lngLat = [event.latlng.lng, event.latlng.lat];
16199
- locationfound({ lngLat });
16200
- };
16201
- if (locationfound !== undefined) {
16202
- map.on('locationfound', locationFound, this);
16203
- }
16204
- if (locationerror) {
16205
- map.on('locationerror', locationerror, this);
16206
- }
16207
- const stop = () => {
16208
- if (locationfound !== undefined) {
16209
- map.off('locationfound', locationFound);
16210
- }
16211
- if (locationerror) {
16212
- map.off('locationerror', locationerror);
16213
- }
16214
- };
16215
- return { stop };
16216
- }
16217
- }
16218
- const stop = () => void 'fake function';
16219
- return { stop };
16434
+ const stop = () => void 0;
16435
+ return { stop };
16436
+ }
16437
+ _addUnselectCb(cb) {
16438
+ for (const p of this._unselectCb) {
16439
+ p();
16220
16440
  }
16221
- _addUnselectCb(cb) {
16222
- for (const p of this._unselectCb) {
16223
- p();
16224
- }
16225
- this._unselectCb.length = 0;
16226
- this._unselectCb.push(cb);
16441
+ this._unselectCb.length = 0;
16442
+ this._unselectCb.push(cb);
16443
+ }
16444
+ _watchSizeChangeToUpdateMinZoom(bounds) {
16445
+ this._stopWatchSizeChangeToUpdateMinZoom();
16446
+ const container = this.getContainer();
16447
+ const map = this.map;
16448
+ if (container && map && window.ResizeObserver) {
16449
+ this._resizeObserver = new ResizeObserver(() => {
16450
+ map.setMinZoom(map.getBoundsZoom(bounds));
16451
+ });
16452
+ this._resizeObserver.observe(container);
16227
16453
  }
16228
- _watchSizeChangeToUpdateMinZoom(bounds) {
16229
- this._stopWatchSizeChangeToUpdateMinZoom();
16230
- const container = this.getContainer();
16231
- const map = this.map;
16232
- if (container && map && window.ResizeObserver) {
16233
- this._resizeObserver = new ResizeObserver(() => {
16234
- map.setMinZoom(map.getBoundsZoom(bounds));
16235
- });
16236
- this._resizeObserver.observe(container);
16237
- }
16454
+ }
16455
+ _stopWatchSizeChangeToUpdateMinZoom() {
16456
+ const map = this.map;
16457
+ if (map) {
16458
+ map.setMinZoom(0);
16238
16459
  }
16239
- _stopWatchSizeChangeToUpdateMinZoom() {
16240
- const map = this.map;
16241
- if (map) {
16242
- map.setMinZoom(0);
16243
- }
16244
- if (this._resizeObserver) {
16245
- this._resizeObserver.disconnect();
16246
- this._resizeObserver = undefined;
16247
- }
16460
+ if (this._resizeObserver) {
16461
+ this._resizeObserver.disconnect();
16462
+ this._resizeObserver = void 0;
16248
16463
  }
16249
- _addMapListeners() {
16250
- const map = this.map;
16251
- if (map) {
16252
- map.on('click', (evt) => {
16253
- this.onMapClick(evt);
16254
- });
16255
- for (const e of this._universalEvents) {
16256
- map.on(e, () => this.emitter.emit(e, this), map);
16257
- }
16258
- for (const e of this._positionEvents) {
16259
- map.on(e, (evt) => this.emitter.emit(e, convertMapClickEvent(evt)), map);
16260
- }
16261
- }
16464
+ }
16465
+ _addMapListeners() {
16466
+ const map = this.map;
16467
+ if (map) {
16468
+ map.on("click", (evt) => {
16469
+ this.onMapClick(evt);
16470
+ });
16471
+ for (const e of this._universalEvents) {
16472
+ map.on(e, () => this.emitter.emit(e, this), map);
16473
+ }
16474
+ for (const e of this._positionEvents) {
16475
+ map.on(
16476
+ e,
16477
+ (evt) => this.emitter.emit(
16478
+ e,
16479
+ convertMapClickEvent(evt)
16480
+ ),
16481
+ map
16482
+ );
16483
+ }
16262
16484
  }
16263
- }
16264
- LeafletMapAdapter$1.layerAdapters = {
16265
- GEOJSON: GeoJsonAdapter,
16266
- IMAGE: ImageAdapter,
16267
- TILE: TileAdapter,
16268
- WMS: WmsAdapter,
16269
- // // MVT: MvtAdapter,
16270
- OSM: OsmAdapter,
16271
- };
16272
- LeafletMapAdapter$1.controlAdapters = {
16273
- ZOOM: leafletSrc.exports.Control.Zoom,
16274
- ATTRIBUTION: AttributionControl,
16485
+ }
16275
16486
  };
16276
- LeafletMapAdapter$1.Map = leafletSrc.exports.Map;
16277
-
16278
- /**
16279
- * @module leaflet-map-adapter
16280
- */
16281
- var LeafletMapAdapter = LeafletMapAdapter$1;
16487
+ __publicField(_LeafletMapAdapter, "layerAdapters", {
16488
+ GEOJSON: GeoJsonAdapter,
16489
+ IMAGE: ImageAdapter,
16490
+ TILE: TileAdapter,
16491
+ WMS: WmsAdapter,
16492
+ // // MVT: MvtAdapter,
16493
+ OSM: OsmAdapter
16494
+ });
16495
+ __publicField(_LeafletMapAdapter, "controlAdapters", {
16496
+ ZOOM: leafletSrcExports.Control.Zoom,
16497
+ ATTRIBUTION: AttributionControl
16498
+ });
16499
+ __publicField(_LeafletMapAdapter, "Map", leafletSrcExports.Map);
16500
+ let LeafletMapAdapter = _LeafletMapAdapter;
16282
16501
 
16283
16502
  export { LeafletMapAdapter as default };
16284
16503
  //# sourceMappingURL=leaflet-map-adapter.esm-browser.js.map