@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,7 +1,7 @@
|
|
|
1
|
-
/** Bundle of @nextgis/leaflet-map-adapter; version: 4.
|
|
1
|
+
/** Bundle of @nextgis/leaflet-map-adapter; version: 4.1.1; 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';
|
|
@@ -104,6 +104,8 @@ function filterGeometries(data, type) {
|
|
|
104
104
|
_data.geometries = _data.geometries.filter(
|
|
105
105
|
(g) => geometryFilter(g.type, type)
|
|
106
106
|
);
|
|
107
|
+
} else if (!geometryFilter(data.type, type)) {
|
|
108
|
+
return false;
|
|
107
109
|
}
|
|
108
110
|
return data;
|
|
109
111
|
}
|
|
@@ -642,6 +644,9 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
642
644
|
}
|
|
643
645
|
setData(data) {
|
|
644
646
|
this.clearLayer();
|
|
647
|
+
if (!this.options.type) {
|
|
648
|
+
this.type = void 0;
|
|
649
|
+
}
|
|
645
650
|
this.addData(data);
|
|
646
651
|
}
|
|
647
652
|
addData(data) {
|
|
@@ -656,15 +661,20 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
656
661
|
} else {
|
|
657
662
|
type = options.type;
|
|
658
663
|
}
|
|
664
|
+
if (!type) {
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
659
667
|
if (this.type && this.type !== type) {
|
|
660
668
|
console.warn("no other data type than layer can be added");
|
|
661
669
|
return;
|
|
662
670
|
}
|
|
663
671
|
this.type = type;
|
|
664
672
|
data = filterGeometries(data, type);
|
|
665
|
-
if (data) {
|
|
666
|
-
|
|
673
|
+
if (!data) {
|
|
674
|
+
console.warn("no other data type than layer can be added");
|
|
675
|
+
return;
|
|
667
676
|
}
|
|
677
|
+
geoJsonOptions = this._getGeoJsonOptions(options, type);
|
|
668
678
|
}
|
|
669
679
|
new GeoJSON(data || void 0, geoJsonOptions);
|
|
670
680
|
}
|
|
@@ -1062,17 +1072,19 @@ function callAjax({
|
|
|
1062
1072
|
return [promise, abortFunc];
|
|
1063
1073
|
}
|
|
1064
1074
|
|
|
1065
|
-
const imageQueue = new Queue({
|
|
1075
|
+
const imageQueue = new Queue({ limit: 6, debounce: 150 });
|
|
1066
1076
|
|
|
1067
1077
|
var __defProp$6 = Object.defineProperty;
|
|
1068
1078
|
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1069
1079
|
var __publicField$3 = (obj, key, value) => __defNormalProp$6(obj, key + "" , value);
|
|
1080
|
+
const transparentImage = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEAAAAALAAAAAABAAEAAAIBAAA=";
|
|
1070
1081
|
class ImageOverlay extends ImageOverlay$1 {
|
|
1071
1082
|
constructor(imageUrl, bounds, options) {
|
|
1072
1083
|
super(imageUrl, bounds, options);
|
|
1073
1084
|
__publicField$3(this, "_aborter");
|
|
1074
1085
|
}
|
|
1075
1086
|
cancelLoad() {
|
|
1087
|
+
imageQueue.remove(Util.stamp(this));
|
|
1076
1088
|
if (this._aborter) {
|
|
1077
1089
|
this._aborter();
|
|
1078
1090
|
this._aborter = void 0;
|
|
@@ -1084,19 +1096,27 @@ class ImageOverlay extends ImageOverlay$1 {
|
|
|
1084
1096
|
const img = this._image;
|
|
1085
1097
|
const src = img.src;
|
|
1086
1098
|
img.src = "";
|
|
1087
|
-
imageQueue.add(
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1099
|
+
imageQueue.add(
|
|
1100
|
+
({ signal }) => {
|
|
1101
|
+
const [promise, abortFunc] = callAjax({
|
|
1102
|
+
src,
|
|
1103
|
+
headers,
|
|
1104
|
+
request,
|
|
1105
|
+
withCredentials
|
|
1106
|
+
});
|
|
1107
|
+
void promise.then((imgUrl) => {
|
|
1108
|
+
if (!signal.aborted) img.src = imgUrl || transparentImage;
|
|
1109
|
+
}).catch((error) => {
|
|
1110
|
+
if (!signal.aborted) {
|
|
1111
|
+
console.error(error);
|
|
1112
|
+
img.src = transparentImage;
|
|
1113
|
+
}
|
|
1114
|
+
});
|
|
1115
|
+
this._aborter = abortFunc;
|
|
1116
|
+
return [promise, abortFunc];
|
|
1117
|
+
},
|
|
1118
|
+
{ id: Util.stamp(this) }
|
|
1119
|
+
);
|
|
1100
1120
|
}
|
|
1101
1121
|
}
|
|
1102
1122
|
|
|
@@ -1166,6 +1186,12 @@ class ImageLayer extends Layer {
|
|
|
1166
1186
|
map.removeLayer(this._currentOverlay);
|
|
1167
1187
|
delete this._currentOverlay;
|
|
1168
1188
|
}
|
|
1189
|
+
if (this._loadedOverlay) {
|
|
1190
|
+
this._loadedOverlay.cancelLoad();
|
|
1191
|
+
this._loadedOverlay.off("load");
|
|
1192
|
+
map.removeLayer(this._loadedOverlay);
|
|
1193
|
+
this._loadedOverlay = void 0;
|
|
1194
|
+
}
|
|
1169
1195
|
if (this._currentUrl) {
|
|
1170
1196
|
delete this._currentUrl;
|
|
1171
1197
|
}
|
|
@@ -1191,6 +1217,7 @@ class ImageLayer extends Layer {
|
|
|
1191
1217
|
if (this._loadedOverlay) {
|
|
1192
1218
|
this._loadedOverlay.cancelLoad();
|
|
1193
1219
|
this._loadedOverlay.off("load");
|
|
1220
|
+
this._map.removeLayer(this._loadedOverlay);
|
|
1194
1221
|
this._loadedOverlay = void 0;
|
|
1195
1222
|
}
|
|
1196
1223
|
const overlay = new ImageOverlay(url, bounds, {
|
|
@@ -1241,6 +1268,7 @@ class ImageLayer extends Layer {
|
|
|
1241
1268
|
if (this._currentOverlay) {
|
|
1242
1269
|
this._currentOverlay.setOpacity(opacity);
|
|
1243
1270
|
}
|
|
1271
|
+
this.fire("opacitychange", { opacity });
|
|
1244
1272
|
}
|
|
1245
1273
|
bringToBack() {
|
|
1246
1274
|
this.options.isBack = true;
|
|
@@ -1869,10 +1897,10 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
|
|
|
1869
1897
|
}
|
|
1870
1898
|
const stop2 = () => {
|
|
1871
1899
|
if (locationfound !== void 0) {
|
|
1872
|
-
map.off("locationfound", locationFound);
|
|
1900
|
+
map.off("locationfound", locationFound, this);
|
|
1873
1901
|
}
|
|
1874
1902
|
if (locationerror) {
|
|
1875
|
-
map.off("locationerror", locationerror);
|
|
1903
|
+
map.off("locationerror", locationerror, this);
|
|
1876
1904
|
}
|
|
1877
1905
|
};
|
|
1878
1906
|
return { stop: stop2 };
|