@nextgis/leaflet-map-adapter 2.3.0 → 2.5.4
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 +35 -27
- 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 +36 -28
- 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 +35 -27
- 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,6 +1,6 @@
|
|
|
1
|
-
/** Bundle of @nextgis/leaflet-map-adapter; version: 2.
|
|
1
|
+
/** Bundle of @nextgis/leaflet-map-adapter; version: 2.5.4; author: NextGIS */
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
|
-
import { Control, DomEvent, GeoJSON, DivIcon, Marker, CircleMarker, FeatureGroup, ImageOverlay as ImageOverlay$1, Layer, Util,
|
|
3
|
+
import { Control, DomEvent, GeoJSON, DivIcon, Marker, CircleMarker, FeatureGroup, ImageOverlay as ImageOverlay$1, Layer, Util, 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
6
|
import Queue from '@nextgis/queue';
|
|
@@ -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
|
});
|
|
@@ -1153,13 +1164,7 @@ class ImageLayer extends Layer {
|
|
|
1153
1164
|
constructor(url, options) {
|
|
1154
1165
|
super(options);
|
|
1155
1166
|
__publicField$2(this, "defaultWmsParams", {
|
|
1156
|
-
|
|
1157
|
-
request: "GetMap",
|
|
1158
|
-
version: "1.1.1",
|
|
1159
|
-
layers: "",
|
|
1160
|
-
styles: "",
|
|
1161
|
-
format: "image/jpeg",
|
|
1162
|
-
transparent: false
|
|
1167
|
+
request: "GetMap"
|
|
1163
1168
|
});
|
|
1164
1169
|
__publicField$2(this, "options", {
|
|
1165
1170
|
crs: null,
|
|
@@ -1170,6 +1175,7 @@ class ImageLayer extends Layer {
|
|
|
1170
1175
|
minZoom: 0,
|
|
1171
1176
|
pane: "tilePane",
|
|
1172
1177
|
headers: null,
|
|
1178
|
+
withCredentials: false,
|
|
1173
1179
|
viewPortBuffer: 0,
|
|
1174
1180
|
setViewDelay: 100
|
|
1175
1181
|
});
|
|
@@ -1239,7 +1245,8 @@ class ImageLayer extends Layer {
|
|
|
1239
1245
|
const overlay = new ImageOverlay(url, bounds, {
|
|
1240
1246
|
opacity: 0,
|
|
1241
1247
|
pane: this.options.pane,
|
|
1242
|
-
headers: this.options.headers
|
|
1248
|
+
headers: this.options.headers,
|
|
1249
|
+
withCredentials: this.options.withCredentials
|
|
1243
1250
|
});
|
|
1244
1251
|
overlay.addTo(this._map);
|
|
1245
1252
|
this._loadedOverlay = overlay;
|
|
@@ -1314,9 +1321,7 @@ class ImageLayer extends Layer {
|
|
|
1314
1321
|
size.x = Math.ceil(size.x * factor);
|
|
1315
1322
|
size.y = Math.ceil(size.y * factor);
|
|
1316
1323
|
}
|
|
1317
|
-
const wmsVersion = parseFloat(this.wmsParams.version);
|
|
1318
1324
|
const crs = this.options.crs || map.options.crs;
|
|
1319
|
-
const projectionKey = wmsVersion >= 1.3 ? "crs" : "srs";
|
|
1320
1325
|
if (crs) {
|
|
1321
1326
|
const nw = crs.project(bounds.getNorthWest());
|
|
1322
1327
|
const se = crs.project(bounds.getSouthEast());
|
|
@@ -1324,8 +1329,7 @@ class ImageLayer extends Layer {
|
|
|
1324
1329
|
width: size.x,
|
|
1325
1330
|
height: size.y
|
|
1326
1331
|
};
|
|
1327
|
-
params
|
|
1328
|
-
params.bbox = (wmsVersion >= 1.3 && crs === CRS.EPSG4326 ? [se.y, nw.x, nw.y, se.x] : [nw.x, se.y, se.x, nw.y]).join(",");
|
|
1332
|
+
params.bbox = [nw.x, se.y, se.x, nw.y];
|
|
1329
1333
|
Util.extend(this.wmsParams, params);
|
|
1330
1334
|
}
|
|
1331
1335
|
}
|
|
@@ -1410,13 +1414,13 @@ function makeRemote(Base) {
|
|
|
1410
1414
|
}
|
|
1411
1415
|
}
|
|
1412
1416
|
createTile(coords, done) {
|
|
1413
|
-
const
|
|
1417
|
+
const src = this.getTileUrl(coords);
|
|
1414
1418
|
const tile = document.createElement("img");
|
|
1415
|
-
const [promise, abortFunc] = callAjax(
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
this.options.headers
|
|
1419
|
-
);
|
|
1419
|
+
const [promise, abortFunc] = callAjax({
|
|
1420
|
+
src,
|
|
1421
|
+
withCredentials: this.options.withCredentials,
|
|
1422
|
+
headers: this.options.headers
|
|
1423
|
+
});
|
|
1420
1424
|
promise.then((response) => {
|
|
1421
1425
|
tile.src = response;
|
|
1422
1426
|
done(null, tile);
|
|
@@ -1506,9 +1510,10 @@ class TileAdapter extends BaseAdapter {
|
|
|
1506
1510
|
tileLayerOptions.subdomains = opt.subdomains;
|
|
1507
1511
|
}
|
|
1508
1512
|
let layer;
|
|
1509
|
-
if (opt.headers) {
|
|
1513
|
+
if (opt.headers || opt.withCredentials) {
|
|
1510
1514
|
layer = new TileLayer(url, __spreadProps$2(__spreadValues$3({}, tileLayerOptions), {
|
|
1511
1515
|
headers: opt.headers,
|
|
1516
|
+
withCredentials: opt.withCredentials,
|
|
1512
1517
|
setViewDelay: opt.setViewDelay
|
|
1513
1518
|
}));
|
|
1514
1519
|
} else {
|
|
@@ -1614,8 +1619,11 @@ class WmsAdapter extends BaseAdapter {
|
|
|
1614
1619
|
transparent: true
|
|
1615
1620
|
}, options.nativeOptions);
|
|
1616
1621
|
let layer;
|
|
1617
|
-
if (opt.headers) {
|
|
1618
|
-
layer = new WmsLayer(url, __spreadProps(__spreadValues$1({}, layerOptions), {
|
|
1622
|
+
if (opt.headers || opt.withCredentials) {
|
|
1623
|
+
layer = new WmsLayer(url, __spreadProps(__spreadValues$1({}, layerOptions), {
|
|
1624
|
+
headers: opt.headers,
|
|
1625
|
+
withCredentials: opt.withCredentials
|
|
1626
|
+
}));
|
|
1619
1627
|
} else {
|
|
1620
1628
|
layer = new TileLayer$1.WMS(url, layerOptions);
|
|
1621
1629
|
}
|