@nextgis/leaflet-map-adapter 3.0.0-alpha.0 → 3.0.0-alpha.12
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/index.d.ts +0 -1
- package/lib/leaflet-map-adapter.esm-browser.js +86 -33
- 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 +71 -33
- 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 +86 -33
- 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 +10 -10
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/** Bundle of @nextgis/leaflet-map-adapter; version: 3.0.0-alpha.
|
|
1
|
+
/** Bundle of @nextgis/leaflet-map-adapter; version: 3.0.0-alpha.5; 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
|
-
import { defined, debounce as debounce$1 } from '@nextgis/utils';
|
|
4
|
+
import { defined, debounce as debounce$1, updateUrlParams } from '@nextgis/utils';
|
|
5
5
|
import { isPaintCallback, isPaint } from '@nextgis/paint';
|
|
6
6
|
import Queue from '@nextgis/queue';
|
|
7
7
|
|
|
@@ -349,8 +349,8 @@ class GeoJsonEvents {
|
|
|
349
349
|
}
|
|
350
350
|
|
|
351
351
|
var __defProp$8 = Object.defineProperty;
|
|
352
|
-
var __defProps$
|
|
353
|
-
var __getOwnPropDescs$
|
|
352
|
+
var __defProps$5 = Object.defineProperties;
|
|
353
|
+
var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
|
|
354
354
|
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
355
355
|
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
356
356
|
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
@@ -366,7 +366,7 @@ var __spreadValues$6 = (a, b) => {
|
|
|
366
366
|
}
|
|
367
367
|
return a;
|
|
368
368
|
};
|
|
369
|
-
var __spreadProps$
|
|
369
|
+
var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
|
|
370
370
|
var __objRest$2 = (source, exclude) => {
|
|
371
371
|
var target = {};
|
|
372
372
|
for (var prop in source)
|
|
@@ -461,7 +461,7 @@ class GeoJsonPaint {
|
|
|
461
461
|
if (html) {
|
|
462
462
|
element.innerHTML = html;
|
|
463
463
|
}
|
|
464
|
-
const divIcon = new DivIcon(__spreadProps$
|
|
464
|
+
const divIcon = new DivIcon(__spreadProps$5(__spreadValues$6({
|
|
465
465
|
className: ""
|
|
466
466
|
}, toLIconOpt), {
|
|
467
467
|
html: element
|
|
@@ -510,8 +510,8 @@ class GeoJsonPaint {
|
|
|
510
510
|
}
|
|
511
511
|
|
|
512
512
|
var __defProp$7 = Object.defineProperty;
|
|
513
|
-
var __defProps$
|
|
514
|
-
var __getOwnPropDescs$
|
|
513
|
+
var __defProps$4 = Object.defineProperties;
|
|
514
|
+
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
515
515
|
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
516
516
|
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
517
517
|
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
@@ -527,7 +527,7 @@ var __spreadValues$5 = (a, b) => {
|
|
|
527
527
|
}
|
|
528
528
|
return a;
|
|
529
529
|
};
|
|
530
|
-
var __spreadProps$
|
|
530
|
+
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
531
531
|
var __publicField$4 = (obj, key, value) => __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
532
532
|
var __async = (__this, __arguments, generator) => {
|
|
533
533
|
return new Promise((resolve, reject) => {
|
|
@@ -576,7 +576,7 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
576
576
|
addLayer(options) {
|
|
577
577
|
Object.assign(this.options, options);
|
|
578
578
|
this.paint = options.paint;
|
|
579
|
-
this.layer = new FeatureGroup([], __spreadProps$
|
|
579
|
+
this.layer = new FeatureGroup([], __spreadProps$4(__spreadValues$5({}, options.nativeOptions), {
|
|
580
580
|
pane: this.pane
|
|
581
581
|
}));
|
|
582
582
|
this.selectedPaint = options.selectedPaint;
|
|
@@ -926,7 +926,7 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
926
926
|
if (feature) {
|
|
927
927
|
return this._paint.preparePaint(__spreadValues$5(__spreadValues$5({}, PAINT), paint(feature)));
|
|
928
928
|
} else {
|
|
929
|
-
return this._paint.preparePaint(__spreadProps$
|
|
929
|
+
return this._paint.preparePaint(__spreadProps$4(__spreadValues$5({}, PAINT), { type: "path" }));
|
|
930
930
|
}
|
|
931
931
|
}
|
|
932
932
|
};
|
|
@@ -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" });
|
|
@@ -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
|
});
|
|
@@ -1151,6 +1162,7 @@ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key,
|
|
|
1151
1162
|
var __publicField$2 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1152
1163
|
class ImageLayer extends Layer {
|
|
1153
1164
|
constructor(url, options) {
|
|
1165
|
+
var _a;
|
|
1154
1166
|
super(options);
|
|
1155
1167
|
__publicField$2(this, "defaultWmsParams", {
|
|
1156
1168
|
service: "WMS",
|
|
@@ -1168,8 +1180,10 @@ class ImageLayer extends Layer {
|
|
|
1168
1180
|
opacity: 1,
|
|
1169
1181
|
isBack: false,
|
|
1170
1182
|
minZoom: 0,
|
|
1183
|
+
maxZoom: void 0,
|
|
1171
1184
|
pane: "tilePane",
|
|
1172
1185
|
headers: null,
|
|
1186
|
+
withCredentials: false,
|
|
1173
1187
|
viewPortBuffer: 0,
|
|
1174
1188
|
setViewDelay: 100
|
|
1175
1189
|
});
|
|
@@ -1190,7 +1204,11 @@ class ImageLayer extends Layer {
|
|
|
1190
1204
|
}
|
|
1191
1205
|
}
|
|
1192
1206
|
Util.setOptions(this, opts);
|
|
1193
|
-
this.wmsParams = Util.extend(
|
|
1207
|
+
this.wmsParams = Util.extend(
|
|
1208
|
+
{},
|
|
1209
|
+
this.defaultWmsParams,
|
|
1210
|
+
(_a = params == null ? void 0 : params.params) != null ? _a : {}
|
|
1211
|
+
);
|
|
1194
1212
|
}
|
|
1195
1213
|
setParams(params) {
|
|
1196
1214
|
Util.extend(this.wmsParams, params);
|
|
@@ -1239,7 +1257,8 @@ class ImageLayer extends Layer {
|
|
|
1239
1257
|
const overlay = new ImageOverlay(url, bounds, {
|
|
1240
1258
|
opacity: 0,
|
|
1241
1259
|
pane: this.options.pane,
|
|
1242
|
-
headers: this.options.headers
|
|
1260
|
+
headers: this.options.headers,
|
|
1261
|
+
withCredentials: this.options.withCredentials
|
|
1243
1262
|
});
|
|
1244
1263
|
overlay.addTo(this._map);
|
|
1245
1264
|
this._loadedOverlay = overlay;
|
|
@@ -1337,6 +1356,8 @@ class ImageLayer extends Layer {
|
|
|
1337
1356
|
}
|
|
1338
1357
|
|
|
1339
1358
|
var __defProp$4 = Object.defineProperty;
|
|
1359
|
+
var __defProps$3 = Object.defineProperties;
|
|
1360
|
+
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
1340
1361
|
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
1341
1362
|
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
1342
1363
|
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
@@ -1352,6 +1373,7 @@ var __spreadValues$4 = (a, b) => {
|
|
|
1352
1373
|
}
|
|
1353
1374
|
return a;
|
|
1354
1375
|
};
|
|
1376
|
+
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
1355
1377
|
var __publicField$1 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1356
1378
|
class ImageAdapter extends BaseAdapter {
|
|
1357
1379
|
constructor() {
|
|
@@ -1359,15 +1381,21 @@ class ImageAdapter extends BaseAdapter {
|
|
|
1359
1381
|
__publicField$1(this, "layer");
|
|
1360
1382
|
}
|
|
1361
1383
|
addLayer(options) {
|
|
1384
|
+
var _a;
|
|
1362
1385
|
const url = options && options.url;
|
|
1363
1386
|
if (url) {
|
|
1364
|
-
options = __spreadValues$4({ transparent: true }, options);
|
|
1365
1387
|
const updateWmsParamsFromOpt = options.updateWmsParams;
|
|
1366
|
-
this.layer = new ImageLayer(url, __spreadValues$4(__spreadValues$4(__spreadValues$4({
|
|
1388
|
+
this.layer = new ImageLayer(url, __spreadProps$3(__spreadValues$4(__spreadValues$4(__spreadValues$4({
|
|
1367
1389
|
pane: this.pane,
|
|
1368
1390
|
headers: options.headers,
|
|
1369
1391
|
setViewDelay: options.setViewDelay
|
|
1370
|
-
},
|
|
1392
|
+
}, __spreadProps$3(__spreadValues$4({
|
|
1393
|
+
transparent: true
|
|
1394
|
+
}, options), {
|
|
1395
|
+
opacity: (_a = options.opacity) != null ? _a : void 0
|
|
1396
|
+
})), options.params), options.nativeOptions), {
|
|
1397
|
+
maxZoom: 12
|
|
1398
|
+
}));
|
|
1371
1399
|
if (updateWmsParamsFromOpt) {
|
|
1372
1400
|
const updateWmsParams = this.layer.updateWmsParams;
|
|
1373
1401
|
this.layer.updateWmsParams = function(map) {
|
|
@@ -1378,6 +1406,13 @@ class ImageAdapter extends BaseAdapter {
|
|
|
1378
1406
|
return this.layer;
|
|
1379
1407
|
}
|
|
1380
1408
|
}
|
|
1409
|
+
updateLayer(options) {
|
|
1410
|
+
if (this.layer) {
|
|
1411
|
+
const params = (options == null ? void 0 : options.params) || {};
|
|
1412
|
+
Util.extend(this.layer.wmsParams, params);
|
|
1413
|
+
this.layer.update();
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1381
1416
|
}
|
|
1382
1417
|
__publicField$1(ImageAdapter, "queue", imageQueue);
|
|
1383
1418
|
|
|
@@ -1410,13 +1445,13 @@ function makeRemote(Base) {
|
|
|
1410
1445
|
}
|
|
1411
1446
|
}
|
|
1412
1447
|
createTile(coords, done) {
|
|
1413
|
-
const
|
|
1448
|
+
const src = this.getTileUrl(coords);
|
|
1414
1449
|
const tile = document.createElement("img");
|
|
1415
|
-
const [promise, abortFunc] = callAjax(
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
this.options.headers
|
|
1419
|
-
);
|
|
1450
|
+
const [promise, abortFunc] = callAjax({
|
|
1451
|
+
src,
|
|
1452
|
+
withCredentials: this.options.withCredentials,
|
|
1453
|
+
headers: this.options.headers
|
|
1454
|
+
});
|
|
1420
1455
|
promise.then((response) => {
|
|
1421
1456
|
tile.src = response;
|
|
1422
1457
|
done(null, tile);
|
|
@@ -1506,9 +1541,10 @@ class TileAdapter extends BaseAdapter {
|
|
|
1506
1541
|
tileLayerOptions.subdomains = opt.subdomains;
|
|
1507
1542
|
}
|
|
1508
1543
|
let layer;
|
|
1509
|
-
if (opt.headers) {
|
|
1544
|
+
if (opt.headers || opt.withCredentials) {
|
|
1510
1545
|
layer = new TileLayer(url, __spreadProps$2(__spreadValues$3({}, tileLayerOptions), {
|
|
1511
1546
|
headers: opt.headers,
|
|
1547
|
+
withCredentials: opt.withCredentials,
|
|
1512
1548
|
setViewDelay: opt.setViewDelay
|
|
1513
1549
|
}));
|
|
1514
1550
|
} else {
|
|
@@ -1518,13 +1554,12 @@ class TileAdapter extends BaseAdapter {
|
|
|
1518
1554
|
}
|
|
1519
1555
|
}
|
|
1520
1556
|
}
|
|
1521
|
-
updateLayer() {
|
|
1557
|
+
updateLayer(options) {
|
|
1522
1558
|
if (this.layer) {
|
|
1523
1559
|
const currentUrl = this.layer._url;
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
this.layer.setUrl(newUrl);
|
|
1560
|
+
if (options == null ? void 0 : options.params) {
|
|
1561
|
+
this.layer.setUrl(updateUrlParams(currentUrl, options.params));
|
|
1562
|
+
}
|
|
1528
1563
|
this.layer.redraw();
|
|
1529
1564
|
}
|
|
1530
1565
|
}
|
|
@@ -1614,8 +1649,11 @@ class WmsAdapter extends BaseAdapter {
|
|
|
1614
1649
|
transparent: true
|
|
1615
1650
|
}, options.nativeOptions);
|
|
1616
1651
|
let layer;
|
|
1617
|
-
if (opt.headers) {
|
|
1618
|
-
layer = new WmsLayer(url, __spreadProps(__spreadValues$1({}, layerOptions), {
|
|
1652
|
+
if (opt.headers || opt.withCredentials) {
|
|
1653
|
+
layer = new WmsLayer(url, __spreadProps(__spreadValues$1({}, layerOptions), {
|
|
1654
|
+
headers: opt.headers,
|
|
1655
|
+
withCredentials: opt.withCredentials
|
|
1656
|
+
}));
|
|
1619
1657
|
} else {
|
|
1620
1658
|
layer = new TileLayer$1.WMS(url, layerOptions);
|
|
1621
1659
|
}
|