@nextgis/leaflet-map-adapter 2.3.0 → 2.5.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 +33 -16
- 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 +33 -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 +33 -16
- 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: 2.
|
|
1
|
+
/** Bundle of @nextgis/leaflet-map-adapter; version: 2.5.0; author: NextGIS */
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
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';
|
|
@@ -379,7 +379,7 @@ var __objRest$2 = (source, exclude) => {
|
|
|
379
379
|
}
|
|
380
380
|
return target;
|
|
381
381
|
};
|
|
382
|
-
var __publicField$5 = (obj, key, value) => __defNormalProp$8(obj,
|
|
382
|
+
var __publicField$5 = (obj, key, value) => __defNormalProp$8(obj, key + "" , value);
|
|
383
383
|
class GeoJsonPaint {
|
|
384
384
|
constructor(layer) {
|
|
385
385
|
__publicField$5(this, "layer");
|
|
@@ -1086,7 +1086,11 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
1086
1086
|
}
|
|
1087
1087
|
}
|
|
1088
1088
|
|
|
1089
|
-
function callAjax(
|
|
1089
|
+
function callAjax({
|
|
1090
|
+
src,
|
|
1091
|
+
headers,
|
|
1092
|
+
withCredentials
|
|
1093
|
+
}) {
|
|
1090
1094
|
let abortFunc = () => {
|
|
1091
1095
|
};
|
|
1092
1096
|
const promise = new Promise((resolve, reject) => {
|
|
@@ -1096,6 +1100,9 @@ function callAjax(src, headers) {
|
|
|
1096
1100
|
for (const h in headers) {
|
|
1097
1101
|
xhr.setRequestHeader(h, headers[h]);
|
|
1098
1102
|
}
|
|
1103
|
+
if (withCredentials) {
|
|
1104
|
+
xhr.withCredentials = withCredentials;
|
|
1105
|
+
}
|
|
1099
1106
|
xhr.onload = function() {
|
|
1100
1107
|
const arrayBufferView = new Uint8Array(this.response);
|
|
1101
1108
|
const blob = new Blob([arrayBufferView], { type: "image/png" });
|
|
@@ -1117,7 +1124,7 @@ const imageQueue = new Queue({ concurrency: 6, delay: 200 });
|
|
|
1117
1124
|
|
|
1118
1125
|
var __defProp$6 = Object.defineProperty;
|
|
1119
1126
|
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1120
|
-
var __publicField$3 = (obj, key, value) => __defNormalProp$6(obj,
|
|
1127
|
+
var __publicField$3 = (obj, key, value) => __defNormalProp$6(obj, key + "" , value);
|
|
1121
1128
|
class ImageOverlay extends ImageOverlay$1 {
|
|
1122
1129
|
constructor(imageUrl, bounds, options) {
|
|
1123
1130
|
super(imageUrl, bounds, options);
|
|
@@ -1131,12 +1138,16 @@ class ImageOverlay extends ImageOverlay$1 {
|
|
|
1131
1138
|
}
|
|
1132
1139
|
_initImage() {
|
|
1133
1140
|
super._initImage();
|
|
1134
|
-
const headers = this.options
|
|
1141
|
+
const { headers, withCredentials } = this.options;
|
|
1135
1142
|
const img = this._image;
|
|
1136
1143
|
const src = img.src;
|
|
1137
1144
|
img.src = "";
|
|
1138
1145
|
imageQueue.add(() => {
|
|
1139
|
-
const [promise, abortFunc] = callAjax(
|
|
1146
|
+
const [promise, abortFunc] = callAjax({
|
|
1147
|
+
src,
|
|
1148
|
+
headers,
|
|
1149
|
+
withCredentials
|
|
1150
|
+
});
|
|
1140
1151
|
promise.then((imgUrl) => {
|
|
1141
1152
|
img.src = imgUrl;
|
|
1142
1153
|
});
|
|
@@ -1170,6 +1181,7 @@ class ImageLayer extends Layer {
|
|
|
1170
1181
|
minZoom: 0,
|
|
1171
1182
|
pane: "tilePane",
|
|
1172
1183
|
headers: null,
|
|
1184
|
+
withCredentials: false,
|
|
1173
1185
|
viewPortBuffer: 0,
|
|
1174
1186
|
setViewDelay: 100
|
|
1175
1187
|
});
|
|
@@ -1239,7 +1251,8 @@ class ImageLayer extends Layer {
|
|
|
1239
1251
|
const overlay = new ImageOverlay(url, bounds, {
|
|
1240
1252
|
opacity: 0,
|
|
1241
1253
|
pane: this.options.pane,
|
|
1242
|
-
headers: this.options.headers
|
|
1254
|
+
headers: this.options.headers,
|
|
1255
|
+
withCredentials: this.options.withCredentials
|
|
1243
1256
|
});
|
|
1244
1257
|
overlay.addTo(this._map);
|
|
1245
1258
|
this._loadedOverlay = overlay;
|
|
@@ -1410,13 +1423,13 @@ function makeRemote(Base) {
|
|
|
1410
1423
|
}
|
|
1411
1424
|
}
|
|
1412
1425
|
createTile(coords, done) {
|
|
1413
|
-
const
|
|
1426
|
+
const src = this.getTileUrl(coords);
|
|
1414
1427
|
const tile = document.createElement("img");
|
|
1415
|
-
const [promise, abortFunc] = callAjax(
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
this.options.headers
|
|
1419
|
-
);
|
|
1428
|
+
const [promise, abortFunc] = callAjax({
|
|
1429
|
+
src,
|
|
1430
|
+
withCredentials: this.options.withCredentials,
|
|
1431
|
+
headers: this.options.headers
|
|
1432
|
+
});
|
|
1420
1433
|
promise.then((response) => {
|
|
1421
1434
|
tile.src = response;
|
|
1422
1435
|
done(null, tile);
|
|
@@ -1506,9 +1519,10 @@ class TileAdapter extends BaseAdapter {
|
|
|
1506
1519
|
tileLayerOptions.subdomains = opt.subdomains;
|
|
1507
1520
|
}
|
|
1508
1521
|
let layer;
|
|
1509
|
-
if (opt.headers) {
|
|
1522
|
+
if (opt.headers || opt.withCredentials) {
|
|
1510
1523
|
layer = new TileLayer(url, __spreadProps$2(__spreadValues$3({}, tileLayerOptions), {
|
|
1511
1524
|
headers: opt.headers,
|
|
1525
|
+
withCredentials: opt.withCredentials,
|
|
1512
1526
|
setViewDelay: opt.setViewDelay
|
|
1513
1527
|
}));
|
|
1514
1528
|
} else {
|
|
@@ -1614,8 +1628,11 @@ class WmsAdapter extends BaseAdapter {
|
|
|
1614
1628
|
transparent: true
|
|
1615
1629
|
}, options.nativeOptions);
|
|
1616
1630
|
let layer;
|
|
1617
|
-
if (opt.headers) {
|
|
1618
|
-
layer = new WmsLayer(url, __spreadProps(__spreadValues$1({}, layerOptions), {
|
|
1631
|
+
if (opt.headers || opt.withCredentials) {
|
|
1632
|
+
layer = new WmsLayer(url, __spreadProps(__spreadValues$1({}, layerOptions), {
|
|
1633
|
+
headers: opt.headers,
|
|
1634
|
+
withCredentials: opt.withCredentials
|
|
1635
|
+
}));
|
|
1619
1636
|
} else {
|
|
1620
1637
|
layer = new TileLayer$1.WMS(url, layerOptions);
|
|
1621
1638
|
}
|