@nextgis/leaflet-map-adapter 4.0.2 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/leaflet-map-adapter.esm-browser.js +209 -49
- package/lib/leaflet-map-adapter.esm-browser.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-browser.prod.js +1 -1
- package/lib/leaflet-map-adapter.esm-browser.prod.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-bundler.js +48 -20
- package/lib/leaflet-map-adapter.esm-bundler.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-bundler.prod.js +1 -1
- package/lib/leaflet-map-adapter.esm-bundler.prod.js.map +1 -1
- package/lib/leaflet-map-adapter.global.js +209 -49
- package/lib/leaflet-map-adapter.global.js.map +1 -1
- package/lib/leaflet-map-adapter.global.prod.js +1 -1
- package/lib/leaflet-map-adapter.global.prod.js.map +1 -1
- package/package.json +7 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/leaflet-map-adapter; version: 4.
|
|
1
|
+
/** Bundle of @nextgis/leaflet-map-adapter; version: 4.1.1; author: NextGIS */
|
|
2
2
|
var LeafletMapAdapter = (function () {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -15471,6 +15471,8 @@ var LeafletMapAdapter = (function () {
|
|
|
15471
15471
|
_data.geometries = _data.geometries.filter(
|
|
15472
15472
|
(g) => geometryFilter(g.type, type)
|
|
15473
15473
|
);
|
|
15474
|
+
} else if (!geometryFilter(data.type, type)) {
|
|
15475
|
+
return false;
|
|
15474
15476
|
}
|
|
15475
15477
|
return data;
|
|
15476
15478
|
}
|
|
@@ -16022,6 +16024,9 @@ var LeafletMapAdapter = (function () {
|
|
|
16022
16024
|
}
|
|
16023
16025
|
setData(data) {
|
|
16024
16026
|
this.clearLayer();
|
|
16027
|
+
if (!this.options.type) {
|
|
16028
|
+
this.type = void 0;
|
|
16029
|
+
}
|
|
16025
16030
|
this.addData(data);
|
|
16026
16031
|
}
|
|
16027
16032
|
addData(data) {
|
|
@@ -16036,15 +16041,20 @@ var LeafletMapAdapter = (function () {
|
|
|
16036
16041
|
} else {
|
|
16037
16042
|
type = options.type;
|
|
16038
16043
|
}
|
|
16044
|
+
if (!type) {
|
|
16045
|
+
return;
|
|
16046
|
+
}
|
|
16039
16047
|
if (this.type && this.type !== type) {
|
|
16040
16048
|
console.warn("no other data type than layer can be added");
|
|
16041
16049
|
return;
|
|
16042
16050
|
}
|
|
16043
16051
|
this.type = type;
|
|
16044
16052
|
data = filterGeometries(data, type);
|
|
16045
|
-
if (data) {
|
|
16046
|
-
|
|
16053
|
+
if (!data) {
|
|
16054
|
+
console.warn("no other data type than layer can be added");
|
|
16055
|
+
return;
|
|
16047
16056
|
}
|
|
16057
|
+
geoJsonOptions = this._getGeoJsonOptions(options, type);
|
|
16048
16058
|
}
|
|
16049
16059
|
new leafletSrcExports.GeoJSON(data || void 0, geoJsonOptions);
|
|
16050
16060
|
}
|
|
@@ -16497,15 +16507,31 @@ var LeafletMapAdapter = (function () {
|
|
|
16497
16507
|
/**
|
|
16498
16508
|
* @param {PromiseQueueOptions} options - Configuration options for the queue.
|
|
16499
16509
|
*/
|
|
16500
|
-
constructor({
|
|
16510
|
+
constructor({
|
|
16511
|
+
delay = 0,
|
|
16512
|
+
limit,
|
|
16513
|
+
timeout,
|
|
16514
|
+
debounce,
|
|
16515
|
+
concurrency = 1
|
|
16516
|
+
} = {}) {
|
|
16501
16517
|
__publicField$4(this, "queue", []);
|
|
16518
|
+
__publicField$4(this, "activeRequests", []);
|
|
16502
16519
|
__publicField$4(this, "concurrency");
|
|
16503
|
-
__publicField$4(this, "activeCount", 0);
|
|
16504
16520
|
__publicField$4(this, "timeoutId");
|
|
16521
|
+
__publicField$4(this, "resumeTimer");
|
|
16505
16522
|
__publicField$4(this, "delay");
|
|
16506
|
-
__publicField$4(this, "
|
|
16507
|
-
this
|
|
16508
|
-
this
|
|
16523
|
+
__publicField$4(this, "timeout");
|
|
16524
|
+
__publicField$4(this, "paused", false);
|
|
16525
|
+
__publicField$4(this, "idleResolvers", []);
|
|
16526
|
+
__publicField$4(this, "debounce");
|
|
16527
|
+
this.concurrency = limit != null ? limit : concurrency;
|
|
16528
|
+
this.delay = debounce != null ? debounce : delay;
|
|
16529
|
+
this.debounce = this.delay;
|
|
16530
|
+
this.timeout = timeout;
|
|
16531
|
+
}
|
|
16532
|
+
setLimit(limit) {
|
|
16533
|
+
this.concurrency = limit;
|
|
16534
|
+
this._next();
|
|
16509
16535
|
}
|
|
16510
16536
|
/**
|
|
16511
16537
|
* Adds a task to the queue, which can be either a simple asynchronous function or an array containing a function and its abort handler.
|
|
@@ -16524,7 +16550,18 @@ var LeafletMapAdapter = (function () {
|
|
|
16524
16550
|
* ```
|
|
16525
16551
|
*/
|
|
16526
16552
|
add(promise, abort) {
|
|
16527
|
-
|
|
16553
|
+
var _a, _b;
|
|
16554
|
+
const options = typeof abort === "function" ? { abort } : abort;
|
|
16555
|
+
if ((options == null ? void 0 : options.id) !== void 0) {
|
|
16556
|
+
this.removeById(options.id);
|
|
16557
|
+
}
|
|
16558
|
+
this.queue.push({
|
|
16559
|
+
id: (_a = options == null ? void 0 : options.id) != null ? _a : Math.random().toString(36).slice(2),
|
|
16560
|
+
promise,
|
|
16561
|
+
abort: options == null ? void 0 : options.abort,
|
|
16562
|
+
abortController: new AbortController(),
|
|
16563
|
+
timeout: (_b = options == null ? void 0 : options.timeout) != null ? _b : this.timeout
|
|
16564
|
+
});
|
|
16528
16565
|
this.debouncedNext();
|
|
16529
16566
|
}
|
|
16530
16567
|
/**
|
|
@@ -16534,60 +16571,167 @@ var LeafletMapAdapter = (function () {
|
|
|
16534
16571
|
* queue.abort(); // Aborts all abortable tasks in the queue.
|
|
16535
16572
|
*/
|
|
16536
16573
|
abort() {
|
|
16537
|
-
for (const
|
|
16538
|
-
|
|
16574
|
+
for (const item of [...this.queue, ...this.activeRequests]) {
|
|
16575
|
+
this.abortRequest(item);
|
|
16576
|
+
this.clearRequestTimeout(item);
|
|
16577
|
+
item.completed = true;
|
|
16578
|
+
}
|
|
16579
|
+
this.queue.length = 0;
|
|
16580
|
+
this.activeRequests.length = 0;
|
|
16581
|
+
this._clearTimeout();
|
|
16582
|
+
this.checkIdle();
|
|
16583
|
+
}
|
|
16584
|
+
remove(id) {
|
|
16585
|
+
this.removeById(id);
|
|
16586
|
+
}
|
|
16587
|
+
clearQueue() {
|
|
16588
|
+
for (const item of this.queue) {
|
|
16589
|
+
this.abortRequest(item);
|
|
16590
|
+
item.completed = true;
|
|
16539
16591
|
}
|
|
16540
|
-
this.
|
|
16541
|
-
this.queue = [];
|
|
16592
|
+
this.queue.length = 0;
|
|
16542
16593
|
this._clearTimeout();
|
|
16594
|
+
this.checkIdle();
|
|
16595
|
+
}
|
|
16596
|
+
waitAll() {
|
|
16597
|
+
return new Promise((resolve) => {
|
|
16598
|
+
if (this.isIdle()) {
|
|
16599
|
+
resolve();
|
|
16600
|
+
} else {
|
|
16601
|
+
this.idleResolvers.push(resolve);
|
|
16602
|
+
}
|
|
16603
|
+
});
|
|
16604
|
+
}
|
|
16605
|
+
pause(pauseDuration) {
|
|
16606
|
+
this.paused = true;
|
|
16607
|
+
this._clearTimeout();
|
|
16608
|
+
this._clearResumeTimer();
|
|
16609
|
+
if (pauseDuration) {
|
|
16610
|
+
this.resumeTimer = setTimeout(() => this.resume(), pauseDuration);
|
|
16611
|
+
}
|
|
16612
|
+
}
|
|
16613
|
+
resume() {
|
|
16614
|
+
if (!this.paused) return;
|
|
16615
|
+
this.paused = false;
|
|
16616
|
+
this._clearResumeTimer();
|
|
16617
|
+
this._next();
|
|
16543
16618
|
}
|
|
16544
16619
|
debouncedNext() {
|
|
16620
|
+
if (this.paused) return;
|
|
16621
|
+
if (this.activeRequests.length) {
|
|
16622
|
+
this._next();
|
|
16623
|
+
return;
|
|
16624
|
+
}
|
|
16545
16625
|
this._clearTimeout();
|
|
16546
16626
|
this.timeoutId = setTimeout(() => this._next(), this.delay);
|
|
16547
16627
|
}
|
|
16548
16628
|
_clearTimeout() {
|
|
16549
16629
|
if (this.timeoutId) {
|
|
16550
16630
|
clearTimeout(this.timeoutId);
|
|
16631
|
+
this.timeoutId = void 0;
|
|
16632
|
+
}
|
|
16633
|
+
}
|
|
16634
|
+
_clearResumeTimer() {
|
|
16635
|
+
if (this.resumeTimer) {
|
|
16636
|
+
clearTimeout(this.resumeTimer);
|
|
16637
|
+
this.resumeTimer = void 0;
|
|
16551
16638
|
}
|
|
16552
16639
|
}
|
|
16553
16640
|
_next() {
|
|
16554
|
-
|
|
16555
|
-
|
|
16556
|
-
this.
|
|
16557
|
-
|
|
16558
|
-
|
|
16559
|
-
|
|
16560
|
-
|
|
16561
|
-
|
|
16562
|
-
|
|
16563
|
-
|
|
16564
|
-
|
|
16565
|
-
|
|
16566
|
-
|
|
16567
|
-
this.toAbort.push(toAbort);
|
|
16641
|
+
if (this.paused) return;
|
|
16642
|
+
while (this.activeRequests.length < this.concurrency && this.queue.length) {
|
|
16643
|
+
const item = this.queue.shift();
|
|
16644
|
+
if (item.abortController.signal.aborted) continue;
|
|
16645
|
+
this.activeRequests.push(item);
|
|
16646
|
+
if (item.timeout && item.timeout > 0) {
|
|
16647
|
+
item.timeoutId = setTimeout(() => {
|
|
16648
|
+
this.abortRequest(
|
|
16649
|
+
item,
|
|
16650
|
+
new DOMException("Request timed out", "TimeoutError")
|
|
16651
|
+
);
|
|
16652
|
+
this.finishRequest(item);
|
|
16653
|
+
}, item.timeout);
|
|
16568
16654
|
}
|
|
16569
|
-
|
|
16570
|
-
|
|
16571
|
-
|
|
16572
|
-
|
|
16655
|
+
try {
|
|
16656
|
+
const execute = item.promise({ signal: item.abortController.signal });
|
|
16657
|
+
const request = Array.isArray(execute) ? execute[0] : execute;
|
|
16658
|
+
if (Array.isArray(execute)) {
|
|
16659
|
+
const abort = item.abort;
|
|
16660
|
+
item.abort = abort ? () => {
|
|
16661
|
+
abort();
|
|
16662
|
+
execute[1]();
|
|
16663
|
+
} : execute[1];
|
|
16573
16664
|
}
|
|
16574
|
-
|
|
16575
|
-
|
|
16665
|
+
Promise.resolve(request).then(
|
|
16666
|
+
() => this.finishRequest(item),
|
|
16667
|
+
() => this.finishRequest(item)
|
|
16668
|
+
);
|
|
16669
|
+
} catch (error) {
|
|
16670
|
+
this.finishRequest(item);
|
|
16671
|
+
console.error(error);
|
|
16672
|
+
}
|
|
16673
|
+
}
|
|
16674
|
+
this.checkIdle();
|
|
16675
|
+
}
|
|
16676
|
+
removeById(id) {
|
|
16677
|
+
this.queue = this.queue.filter((item) => {
|
|
16678
|
+
if (item.id !== id) return true;
|
|
16679
|
+
this.abortRequest(item);
|
|
16680
|
+
item.completed = true;
|
|
16681
|
+
return false;
|
|
16682
|
+
});
|
|
16683
|
+
for (const item of [...this.activeRequests]) {
|
|
16684
|
+
if (item.id === id) {
|
|
16685
|
+
this.abortRequest(item);
|
|
16686
|
+
this.finishRequest(item);
|
|
16687
|
+
}
|
|
16688
|
+
}
|
|
16689
|
+
this.checkIdle();
|
|
16690
|
+
}
|
|
16691
|
+
abortRequest(item, reason) {
|
|
16692
|
+
var _a;
|
|
16693
|
+
if (!item.abortController.signal.aborted) {
|
|
16694
|
+
item.abortController.abort(reason);
|
|
16695
|
+
}
|
|
16696
|
+
(_a = item.abort) == null ? void 0 : _a.call(item);
|
|
16697
|
+
}
|
|
16698
|
+
clearRequestTimeout(item) {
|
|
16699
|
+
if (item.timeoutId) {
|
|
16700
|
+
clearTimeout(item.timeoutId);
|
|
16701
|
+
item.timeoutId = void 0;
|
|
16702
|
+
}
|
|
16703
|
+
}
|
|
16704
|
+
finishRequest(item) {
|
|
16705
|
+
if (item.completed) return;
|
|
16706
|
+
item.completed = true;
|
|
16707
|
+
this.clearRequestTimeout(item);
|
|
16708
|
+
this.activeRequests = this.activeRequests.filter((x) => x !== item);
|
|
16709
|
+
this.checkIdle();
|
|
16710
|
+
this._next();
|
|
16711
|
+
}
|
|
16712
|
+
isIdle() {
|
|
16713
|
+
return this.queue.length === 0 && this.activeRequests.length === 0;
|
|
16714
|
+
}
|
|
16715
|
+
checkIdle() {
|
|
16716
|
+
if (this.isIdle()) {
|
|
16717
|
+
this.idleResolvers.splice(0).forEach((resolve) => resolve());
|
|
16576
16718
|
}
|
|
16577
16719
|
}
|
|
16578
16720
|
}
|
|
16579
16721
|
|
|
16580
|
-
const imageQueue = new Queue({
|
|
16722
|
+
const imageQueue = new Queue({ limit: 6, debounce: 150 });
|
|
16581
16723
|
|
|
16582
16724
|
var __defProp$6 = Object.defineProperty;
|
|
16583
16725
|
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
16584
16726
|
var __publicField$3 = (obj, key, value) => __defNormalProp$6(obj, key + "" , value);
|
|
16727
|
+
const transparentImage = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEAAAAALAAAAAABAAEAAAIBAAA=";
|
|
16585
16728
|
class ImageOverlay extends leafletSrcExports.ImageOverlay {
|
|
16586
16729
|
constructor(imageUrl, bounds, options) {
|
|
16587
16730
|
super(imageUrl, bounds, options);
|
|
16588
16731
|
__publicField$3(this, "_aborter");
|
|
16589
16732
|
}
|
|
16590
16733
|
cancelLoad() {
|
|
16734
|
+
imageQueue.remove(leafletSrcExports.Util.stamp(this));
|
|
16591
16735
|
if (this._aborter) {
|
|
16592
16736
|
this._aborter();
|
|
16593
16737
|
this._aborter = void 0;
|
|
@@ -16599,19 +16743,27 @@ var LeafletMapAdapter = (function () {
|
|
|
16599
16743
|
const img = this._image;
|
|
16600
16744
|
const src = img.src;
|
|
16601
16745
|
img.src = "";
|
|
16602
|
-
imageQueue.add(
|
|
16603
|
-
|
|
16604
|
-
|
|
16605
|
-
|
|
16606
|
-
|
|
16607
|
-
|
|
16608
|
-
|
|
16609
|
-
|
|
16610
|
-
|
|
16611
|
-
|
|
16612
|
-
|
|
16613
|
-
|
|
16614
|
-
|
|
16746
|
+
imageQueue.add(
|
|
16747
|
+
({ signal }) => {
|
|
16748
|
+
const [promise, abortFunc] = callAjax({
|
|
16749
|
+
src,
|
|
16750
|
+
headers,
|
|
16751
|
+
request,
|
|
16752
|
+
withCredentials
|
|
16753
|
+
});
|
|
16754
|
+
void promise.then((imgUrl) => {
|
|
16755
|
+
if (!signal.aborted) img.src = imgUrl || transparentImage;
|
|
16756
|
+
}).catch((error) => {
|
|
16757
|
+
if (!signal.aborted) {
|
|
16758
|
+
console.error(error);
|
|
16759
|
+
img.src = transparentImage;
|
|
16760
|
+
}
|
|
16761
|
+
});
|
|
16762
|
+
this._aborter = abortFunc;
|
|
16763
|
+
return [promise, abortFunc];
|
|
16764
|
+
},
|
|
16765
|
+
{ id: leafletSrcExports.Util.stamp(this) }
|
|
16766
|
+
);
|
|
16615
16767
|
}
|
|
16616
16768
|
}
|
|
16617
16769
|
|
|
@@ -16681,6 +16833,12 @@ var LeafletMapAdapter = (function () {
|
|
|
16681
16833
|
map.removeLayer(this._currentOverlay);
|
|
16682
16834
|
delete this._currentOverlay;
|
|
16683
16835
|
}
|
|
16836
|
+
if (this._loadedOverlay) {
|
|
16837
|
+
this._loadedOverlay.cancelLoad();
|
|
16838
|
+
this._loadedOverlay.off("load");
|
|
16839
|
+
map.removeLayer(this._loadedOverlay);
|
|
16840
|
+
this._loadedOverlay = void 0;
|
|
16841
|
+
}
|
|
16684
16842
|
if (this._currentUrl) {
|
|
16685
16843
|
delete this._currentUrl;
|
|
16686
16844
|
}
|
|
@@ -16706,6 +16864,7 @@ var LeafletMapAdapter = (function () {
|
|
|
16706
16864
|
if (this._loadedOverlay) {
|
|
16707
16865
|
this._loadedOverlay.cancelLoad();
|
|
16708
16866
|
this._loadedOverlay.off("load");
|
|
16867
|
+
this._map.removeLayer(this._loadedOverlay);
|
|
16709
16868
|
this._loadedOverlay = void 0;
|
|
16710
16869
|
}
|
|
16711
16870
|
const overlay = new ImageOverlay(url, bounds, {
|
|
@@ -16756,6 +16915,7 @@ var LeafletMapAdapter = (function () {
|
|
|
16756
16915
|
if (this._currentOverlay) {
|
|
16757
16916
|
this._currentOverlay.setOpacity(opacity);
|
|
16758
16917
|
}
|
|
16918
|
+
this.fire("opacitychange", { opacity });
|
|
16759
16919
|
}
|
|
16760
16920
|
bringToBack() {
|
|
16761
16921
|
this.options.isBack = true;
|
|
@@ -17366,10 +17526,10 @@ var LeafletMapAdapter = (function () {
|
|
|
17366
17526
|
}
|
|
17367
17527
|
const stop2 = () => {
|
|
17368
17528
|
if (locationfound !== void 0) {
|
|
17369
|
-
map.off("locationfound", locationFound);
|
|
17529
|
+
map.off("locationfound", locationFound, this);
|
|
17370
17530
|
}
|
|
17371
17531
|
if (locationerror) {
|
|
17372
|
-
map.off("locationerror", locationerror);
|
|
17532
|
+
map.off("locationerror", locationerror, this);
|
|
17373
17533
|
}
|
|
17374
17534
|
};
|
|
17375
17535
|
return { stop: stop2 };
|