@nextgis/leaflet-map-adapter 4.0.1 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/leaflet-map-adapter.esm-browser.js +204 -48
- 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 +34 -16
- 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 +204 -48
- 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 +8 -8
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/** Bundle of @nextgis/leaflet-map-adapter; version: 4.0
|
|
1
|
+
/** Bundle of @nextgis/leaflet-map-adapter; version: 4.1.0; author: NextGIS */
|
|
2
2
|
import { LeafletControlContainer, createControl, createButtonControl, createToggleControl } from '@nextgis/leaflet-control-container';
|
|
3
3
|
import { EventEmitter } from 'events';
|
|
4
|
-
import { Control, GeoJSON, DomEvent, DivIcon, Marker, CircleMarker, FeatureGroup, ImageOverlay as ImageOverlay$1,
|
|
4
|
+
import { Control, GeoJSON, DomEvent, DivIcon, Marker, CircleMarker, FeatureGroup, ImageOverlay as ImageOverlay$1, Util, Layer, GridLayer, DomUtil, TileLayer as TileLayer$1, Map, latLngBounds, latLng } from 'leaflet';
|
|
5
5
|
import { defined, debounce as debounce$1, isObject, updateUrlParams } from '@nextgis/utils';
|
|
6
6
|
import { isPaintCallback, isPaint } from '@nextgis/paint';
|
|
7
7
|
import { getLayerRequestOptions } from '@nextgis/webmap';
|
|
@@ -1062,17 +1062,19 @@ function callAjax({
|
|
|
1062
1062
|
return [promise, abortFunc];
|
|
1063
1063
|
}
|
|
1064
1064
|
|
|
1065
|
-
const imageQueue = new Queue({
|
|
1065
|
+
const imageQueue = new Queue({ limit: 6, debounce: 150 });
|
|
1066
1066
|
|
|
1067
1067
|
var __defProp$6 = Object.defineProperty;
|
|
1068
1068
|
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1069
1069
|
var __publicField$3 = (obj, key, value) => __defNormalProp$6(obj, key + "" , value);
|
|
1070
|
+
const transparentImage = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEAAAAALAAAAAABAAEAAAIBAAA=";
|
|
1070
1071
|
class ImageOverlay extends ImageOverlay$1 {
|
|
1071
1072
|
constructor(imageUrl, bounds, options) {
|
|
1072
1073
|
super(imageUrl, bounds, options);
|
|
1073
1074
|
__publicField$3(this, "_aborter");
|
|
1074
1075
|
}
|
|
1075
1076
|
cancelLoad() {
|
|
1077
|
+
imageQueue.remove(Util.stamp(this));
|
|
1076
1078
|
if (this._aborter) {
|
|
1077
1079
|
this._aborter();
|
|
1078
1080
|
this._aborter = void 0;
|
|
@@ -1084,19 +1086,27 @@ class ImageOverlay extends ImageOverlay$1 {
|
|
|
1084
1086
|
const img = this._image;
|
|
1085
1087
|
const src = img.src;
|
|
1086
1088
|
img.src = "";
|
|
1087
|
-
imageQueue.add(
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1089
|
+
imageQueue.add(
|
|
1090
|
+
({ signal }) => {
|
|
1091
|
+
const [promise, abortFunc] = callAjax({
|
|
1092
|
+
src,
|
|
1093
|
+
headers,
|
|
1094
|
+
request,
|
|
1095
|
+
withCredentials
|
|
1096
|
+
});
|
|
1097
|
+
void promise.then((imgUrl) => {
|
|
1098
|
+
if (!signal.aborted) img.src = imgUrl || transparentImage;
|
|
1099
|
+
}).catch((error) => {
|
|
1100
|
+
if (!signal.aborted) {
|
|
1101
|
+
console.error(error);
|
|
1102
|
+
img.src = transparentImage;
|
|
1103
|
+
}
|
|
1104
|
+
});
|
|
1105
|
+
this._aborter = abortFunc;
|
|
1106
|
+
return [promise, abortFunc];
|
|
1107
|
+
},
|
|
1108
|
+
{ id: Util.stamp(this) }
|
|
1109
|
+
);
|
|
1100
1110
|
}
|
|
1101
1111
|
}
|
|
1102
1112
|
|
|
@@ -1166,6 +1176,12 @@ class ImageLayer extends Layer {
|
|
|
1166
1176
|
map.removeLayer(this._currentOverlay);
|
|
1167
1177
|
delete this._currentOverlay;
|
|
1168
1178
|
}
|
|
1179
|
+
if (this._loadedOverlay) {
|
|
1180
|
+
this._loadedOverlay.cancelLoad();
|
|
1181
|
+
this._loadedOverlay.off("load");
|
|
1182
|
+
map.removeLayer(this._loadedOverlay);
|
|
1183
|
+
this._loadedOverlay = void 0;
|
|
1184
|
+
}
|
|
1169
1185
|
if (this._currentUrl) {
|
|
1170
1186
|
delete this._currentUrl;
|
|
1171
1187
|
}
|
|
@@ -1191,6 +1207,7 @@ class ImageLayer extends Layer {
|
|
|
1191
1207
|
if (this._loadedOverlay) {
|
|
1192
1208
|
this._loadedOverlay.cancelLoad();
|
|
1193
1209
|
this._loadedOverlay.off("load");
|
|
1210
|
+
this._map.removeLayer(this._loadedOverlay);
|
|
1194
1211
|
this._loadedOverlay = void 0;
|
|
1195
1212
|
}
|
|
1196
1213
|
const overlay = new ImageOverlay(url, bounds, {
|
|
@@ -1241,6 +1258,7 @@ class ImageLayer extends Layer {
|
|
|
1241
1258
|
if (this._currentOverlay) {
|
|
1242
1259
|
this._currentOverlay.setOpacity(opacity);
|
|
1243
1260
|
}
|
|
1261
|
+
this.fire("opacitychange", { opacity });
|
|
1244
1262
|
}
|
|
1245
1263
|
bringToBack() {
|
|
1246
1264
|
this.options.isBack = true;
|