@nextgis/leaflet-map-adapter 2.2.0 → 2.2.2
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 +187 -84
- 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 +52 -38
- 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 +187 -84
- 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 +3 -2
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
/** Bundle of @nextgis/leaflet-map-adapter; version: 2.2.
|
|
1
|
+
/** Bundle of @nextgis/leaflet-map-adapter; version: 2.2.2; author: NextGIS */
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
|
-
import { Control, DomEvent, GeoJSON, DivIcon, Marker, CircleMarker, FeatureGroup, ImageOverlay as ImageOverlay$1,
|
|
3
|
+
import { Control, DomEvent, GeoJSON, DivIcon, Marker, CircleMarker, FeatureGroup, ImageOverlay as ImageOverlay$1, Layer, Util, CRS, GridLayer, DomUtil, TileLayer as TileLayer$1, Map, latLngBounds, latLng } from 'leaflet';
|
|
4
4
|
import { defined, debounce as debounce$1 } from '@nextgis/utils';
|
|
5
5
|
import { isPaintCallback, isPaint } from '@nextgis/paint';
|
|
6
|
+
import Queue from '@nextgis/queue';
|
|
6
7
|
|
|
7
8
|
class AttributionControl extends Control.Attribution {
|
|
8
9
|
// options: AttributionControlOptions
|
|
@@ -1086,26 +1087,36 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
1086
1087
|
}
|
|
1087
1088
|
}
|
|
1088
1089
|
|
|
1089
|
-
function callAjax(src,
|
|
1090
|
-
|
|
1091
|
-
xhr.open("GET", src);
|
|
1092
|
-
xhr.responseType = "arraybuffer";
|
|
1093
|
-
for (const h in headers) {
|
|
1094
|
-
xhr.setRequestHeader(h, headers[h]);
|
|
1095
|
-
}
|
|
1096
|
-
xhr.onload = function() {
|
|
1097
|
-
const arrayBufferView = new Uint8Array(this.response);
|
|
1098
|
-
const blob = new Blob([arrayBufferView], { type: "image/png" });
|
|
1099
|
-
const urlCreator = window.URL || window.webkitURL;
|
|
1100
|
-
const imageUrl = urlCreator.createObjectURL(blob);
|
|
1101
|
-
callback(imageUrl);
|
|
1102
|
-
};
|
|
1103
|
-
xhr.send();
|
|
1104
|
-
return () => {
|
|
1105
|
-
xhr.abort();
|
|
1090
|
+
function callAjax(src, headers) {
|
|
1091
|
+
let abortFunc = () => {
|
|
1106
1092
|
};
|
|
1093
|
+
const promise = new Promise((resolve, reject) => {
|
|
1094
|
+
const xhr = new XMLHttpRequest();
|
|
1095
|
+
xhr.open("GET", src);
|
|
1096
|
+
xhr.responseType = "arraybuffer";
|
|
1097
|
+
for (const h in headers) {
|
|
1098
|
+
xhr.setRequestHeader(h, headers[h]);
|
|
1099
|
+
}
|
|
1100
|
+
xhr.onload = function() {
|
|
1101
|
+
const arrayBufferView = new Uint8Array(this.response);
|
|
1102
|
+
const blob = new Blob([arrayBufferView], { type: "image/png" });
|
|
1103
|
+
const urlCreator = window.URL || window.webkitURL;
|
|
1104
|
+
const imageUrl = urlCreator.createObjectURL(blob);
|
|
1105
|
+
resolve(imageUrl);
|
|
1106
|
+
};
|
|
1107
|
+
xhr.onerror = reject;
|
|
1108
|
+
xhr.send();
|
|
1109
|
+
abortFunc = () => {
|
|
1110
|
+
xhr.abort();
|
|
1111
|
+
resolve("");
|
|
1112
|
+
};
|
|
1113
|
+
});
|
|
1114
|
+
return [promise, abortFunc];
|
|
1107
1115
|
}
|
|
1108
1116
|
|
|
1117
|
+
const imageQueue = new Queue({ concurrency: 6, delay: 200 });
|
|
1118
|
+
var imageQueue$1 = imageQueue;
|
|
1119
|
+
|
|
1109
1120
|
var __defProp$6 = Object.defineProperty;
|
|
1110
1121
|
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1111
1122
|
var __publicField$3 = (obj, key, value) => {
|
|
@@ -1128,20 +1139,15 @@ class ImageOverlay extends ImageOverlay$1 {
|
|
|
1128
1139
|
const headers = this.options.headers;
|
|
1129
1140
|
const img = this._image;
|
|
1130
1141
|
const src = img.src;
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
} else {
|
|
1141
|
-
this._aborter = () => {
|
|
1142
|
-
img.setAttribute("src", Util.emptyImageUrl);
|
|
1143
|
-
};
|
|
1144
|
-
}
|
|
1142
|
+
img.src = "";
|
|
1143
|
+
imageQueue$1.add(() => {
|
|
1144
|
+
const [promise, abortFunc] = callAjax(src, headers);
|
|
1145
|
+
promise.then((imgUrl) => {
|
|
1146
|
+
img.src = imgUrl;
|
|
1147
|
+
});
|
|
1148
|
+
this._aborter = abortFunc;
|
|
1149
|
+
return promise;
|
|
1150
|
+
});
|
|
1145
1151
|
}
|
|
1146
1152
|
}
|
|
1147
1153
|
|
|
@@ -1384,6 +1390,7 @@ class ImageAdapter extends BaseAdapter {
|
|
|
1384
1390
|
}
|
|
1385
1391
|
}
|
|
1386
1392
|
}
|
|
1393
|
+
__publicField$1(ImageAdapter, "queue", imageQueue$1);
|
|
1387
1394
|
|
|
1388
1395
|
function debounce(cb, wait = 10) {
|
|
1389
1396
|
let timeoutId;
|
|
@@ -1416,15 +1423,16 @@ function makeRemote(Base) {
|
|
|
1416
1423
|
createTile(coords, done) {
|
|
1417
1424
|
const url = this.getTileUrl(coords);
|
|
1418
1425
|
const tile = document.createElement("img");
|
|
1419
|
-
|
|
1426
|
+
const [promise, abortFunc] = callAjax(
|
|
1420
1427
|
url,
|
|
1421
|
-
(response) => {
|
|
1422
|
-
tile.src = response;
|
|
1423
|
-
done(null, tile);
|
|
1424
|
-
},
|
|
1425
1428
|
// @ts-ignore
|
|
1426
1429
|
this.options.headers
|
|
1427
1430
|
);
|
|
1431
|
+
promise.then((response) => {
|
|
1432
|
+
tile.src = response;
|
|
1433
|
+
done(null, tile);
|
|
1434
|
+
});
|
|
1435
|
+
tile.abort = abortFunc;
|
|
1428
1436
|
if (this.options.crossOrigin || this.options.crossOrigin === "") {
|
|
1429
1437
|
tile.crossOrigin = this.options.crossOrigin === true ? "" : this.options.crossOrigin;
|
|
1430
1438
|
}
|
|
@@ -1933,6 +1941,12 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
|
|
|
1933
1941
|
for (const e of this._universalEvents) {
|
|
1934
1942
|
map.on(e, () => this.emitter.emit(e, this), map);
|
|
1935
1943
|
}
|
|
1944
|
+
map.on("movestart", () => {
|
|
1945
|
+
ImageAdapter.queue.abort();
|
|
1946
|
+
});
|
|
1947
|
+
map.on("zoomstart", () => {
|
|
1948
|
+
ImageAdapter.queue.abort();
|
|
1949
|
+
});
|
|
1936
1950
|
for (const e of this._positionEvents) {
|
|
1937
1951
|
map.on(
|
|
1938
1952
|
e,
|