@nextgis/leaflet-map-adapter 2.2.3 → 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.
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/leaflet-map-adapter; version: 2.2.3; author: NextGIS */
1
+ /** Bundle of @nextgis/leaflet-map-adapter; version: 2.5.0; author: NextGIS */
2
2
  var domain;
3
3
 
4
4
  // This constructor is used to store event handlers. Instantiating this is
@@ -14758,10 +14758,7 @@ function createFeaturePositionOptions(features) {
14758
14758
 
14759
14759
  var __defProp$c = Object.defineProperty;
14760
14760
  var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14761
- var __publicField$8 = (obj, key, value) => {
14762
- __defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
14763
- return value;
14764
- };
14761
+ var __publicField$8 = (obj, key, value) => __defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
14765
14762
  class BaseAdapter {
14766
14763
  constructor(map, options) {
14767
14764
  this.map = map;
@@ -14843,10 +14840,7 @@ var __spreadValues$7 = (a, b) => {
14843
14840
  }
14844
14841
  return a;
14845
14842
  };
14846
- var __publicField$7 = (obj, key, value) => {
14847
- __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
14848
- return value;
14849
- };
14843
+ var __publicField$7 = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
14850
14844
  class GeoJsonEvents {
14851
14845
  constructor(layer) {
14852
14846
  __publicField$7(this, "layer");
@@ -14954,10 +14948,7 @@ var __objRest$2 = (source, exclude) => {
14954
14948
  }
14955
14949
  return target;
14956
14950
  };
14957
- var __publicField$6 = (obj, key, value) => {
14958
- __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
14959
- return value;
14960
- };
14951
+ var __publicField$6 = (obj, key, value) => __defNormalProp$9(obj, key + "" , value);
14961
14952
  class GeoJsonPaint {
14962
14953
  constructor(layer) {
14963
14954
  __publicField$6(this, "layer");
@@ -15106,10 +15097,7 @@ var __spreadValues$5 = (a, b) => {
15106
15097
  return a;
15107
15098
  };
15108
15099
  var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
15109
- var __publicField$5 = (obj, key, value) => {
15110
- __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
15111
- return value;
15112
- };
15100
+ var __publicField$5 = (obj, key, value) => __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
15113
15101
  var __async = (__this, __arguments, generator) => {
15114
15102
  return new Promise((resolve, reject) => {
15115
15103
  var fulfilled = (value) => {
@@ -15667,7 +15655,11 @@ class GeoJsonAdapter extends BaseAdapter {
15667
15655
  }
15668
15656
  }
15669
15657
 
15670
- function callAjax(src, headers) {
15658
+ function callAjax({
15659
+ src,
15660
+ headers,
15661
+ withCredentials
15662
+ }) {
15671
15663
  let abortFunc = () => {
15672
15664
  };
15673
15665
  const promise = new Promise((resolve, reject) => {
@@ -15677,6 +15669,9 @@ function callAjax(src, headers) {
15677
15669
  for (const h in headers) {
15678
15670
  xhr.setRequestHeader(h, headers[h]);
15679
15671
  }
15672
+ if (withCredentials) {
15673
+ xhr.withCredentials = withCredentials;
15674
+ }
15680
15675
  xhr.onload = function() {
15681
15676
  const arrayBufferView = new Uint8Array(this.response);
15682
15677
  const blob = new Blob([arrayBufferView], { type: "image/png" });
@@ -15696,10 +15691,7 @@ function callAjax(src, headers) {
15696
15691
 
15697
15692
  var __defProp$7 = Object.defineProperty;
15698
15693
  var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15699
- var __publicField$4 = (obj, key, value) => {
15700
- __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
15701
- return value;
15702
- };
15694
+ var __publicField$4 = (obj, key, value) => __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
15703
15695
  class Queue {
15704
15696
  /**
15705
15697
  * @param {PromiseQueueOptions} options - Configuration options for the queue.
@@ -15785,14 +15777,10 @@ class Queue {
15785
15777
  }
15786
15778
 
15787
15779
  const imageQueue = new Queue({ concurrency: 6, delay: 200 });
15788
- var imageQueue$1 = imageQueue;
15789
15780
 
15790
15781
  var __defProp$6 = Object.defineProperty;
15791
15782
  var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15792
- var __publicField$3 = (obj, key, value) => {
15793
- __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
15794
- return value;
15795
- };
15783
+ var __publicField$3 = (obj, key, value) => __defNormalProp$6(obj, key + "" , value);
15796
15784
  class ImageOverlay extends leafletSrcExports.ImageOverlay {
15797
15785
  constructor(imageUrl, bounds, options) {
15798
15786
  super(imageUrl, bounds, options);
@@ -15806,12 +15794,16 @@ class ImageOverlay extends leafletSrcExports.ImageOverlay {
15806
15794
  }
15807
15795
  _initImage() {
15808
15796
  super._initImage();
15809
- const headers = this.options.headers;
15797
+ const { headers, withCredentials } = this.options;
15810
15798
  const img = this._image;
15811
15799
  const src = img.src;
15812
15800
  img.src = "";
15813
- imageQueue$1.add(() => {
15814
- const [promise, abortFunc] = callAjax(src, headers);
15801
+ imageQueue.add(() => {
15802
+ const [promise, abortFunc] = callAjax({
15803
+ src,
15804
+ headers,
15805
+ withCredentials
15806
+ });
15815
15807
  promise.then((imgUrl) => {
15816
15808
  img.src = imgUrl;
15817
15809
  });
@@ -15823,10 +15815,7 @@ class ImageOverlay extends leafletSrcExports.ImageOverlay {
15823
15815
 
15824
15816
  var __defProp$5 = Object.defineProperty;
15825
15817
  var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15826
- var __publicField$2 = (obj, key, value) => {
15827
- __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
15828
- return value;
15829
- };
15818
+ var __publicField$2 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
15830
15819
  class ImageLayer extends leafletSrcExports.Layer {
15831
15820
  constructor(url, options) {
15832
15821
  super(options);
@@ -15848,6 +15837,7 @@ class ImageLayer extends leafletSrcExports.Layer {
15848
15837
  minZoom: 0,
15849
15838
  pane: "tilePane",
15850
15839
  headers: null,
15840
+ withCredentials: false,
15851
15841
  viewPortBuffer: 0,
15852
15842
  setViewDelay: 100
15853
15843
  });
@@ -15917,7 +15907,8 @@ class ImageLayer extends leafletSrcExports.Layer {
15917
15907
  const overlay = new ImageOverlay(url, bounds, {
15918
15908
  opacity: 0,
15919
15909
  pane: this.options.pane,
15920
- headers: this.options.headers
15910
+ headers: this.options.headers,
15911
+ withCredentials: this.options.withCredentials
15921
15912
  });
15922
15913
  overlay.addTo(this._map);
15923
15914
  this._loadedOverlay = overlay;
@@ -16030,10 +16021,7 @@ var __spreadValues$4 = (a, b) => {
16030
16021
  }
16031
16022
  return a;
16032
16023
  };
16033
- var __publicField$1 = (obj, key, value) => {
16034
- __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
16035
- return value;
16036
- };
16024
+ var __publicField$1 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
16037
16025
  class ImageAdapter extends BaseAdapter {
16038
16026
  constructor() {
16039
16027
  super(...arguments);
@@ -16060,7 +16048,7 @@ class ImageAdapter extends BaseAdapter {
16060
16048
  }
16061
16049
  }
16062
16050
  }
16063
- __publicField$1(ImageAdapter, "queue", imageQueue$1);
16051
+ __publicField$1(ImageAdapter, "queue", imageQueue);
16064
16052
 
16065
16053
  function makeRemote(Base) {
16066
16054
  return class RemoteTileLayer extends Base {
@@ -16073,13 +16061,13 @@ function makeRemote(Base) {
16073
16061
  }
16074
16062
  }
16075
16063
  createTile(coords, done) {
16076
- const url = this.getTileUrl(coords);
16064
+ const src = this.getTileUrl(coords);
16077
16065
  const tile = document.createElement("img");
16078
- const [promise, abortFunc] = callAjax(
16079
- url,
16080
- // @ts-ignore
16081
- this.options.headers
16082
- );
16066
+ const [promise, abortFunc] = callAjax({
16067
+ src,
16068
+ withCredentials: this.options.withCredentials,
16069
+ headers: this.options.headers
16070
+ });
16083
16071
  promise.then((response) => {
16084
16072
  tile.src = response;
16085
16073
  done(null, tile);
@@ -16169,9 +16157,10 @@ class TileAdapter extends BaseAdapter {
16169
16157
  tileLayerOptions.subdomains = opt.subdomains;
16170
16158
  }
16171
16159
  let layer;
16172
- if (opt.headers) {
16160
+ if (opt.headers || opt.withCredentials) {
16173
16161
  layer = new TileLayer(url, __spreadProps$2(__spreadValues$3({}, tileLayerOptions), {
16174
16162
  headers: opt.headers,
16163
+ withCredentials: opt.withCredentials,
16175
16164
  setViewDelay: opt.setViewDelay
16176
16165
  }));
16177
16166
  } else {
@@ -16277,8 +16266,11 @@ class WmsAdapter extends BaseAdapter {
16277
16266
  transparent: true
16278
16267
  }, options.nativeOptions);
16279
16268
  let layer;
16280
- if (opt.headers) {
16281
- layer = new WmsLayer(url, __spreadProps(__spreadValues$1({}, layerOptions), { headers: opt.headers }));
16269
+ if (opt.headers || opt.withCredentials) {
16270
+ layer = new WmsLayer(url, __spreadProps(__spreadValues$1({}, layerOptions), {
16271
+ headers: opt.headers,
16272
+ withCredentials: opt.withCredentials
16273
+ }));
16282
16274
  } else {
16283
16275
  layer = new leafletSrcExports.TileLayer.WMS(url, layerOptions);
16284
16276
  }
@@ -16311,10 +16303,7 @@ var __spreadValues = (a, b) => {
16311
16303
  }
16312
16304
  return a;
16313
16305
  };
16314
- var __publicField = (obj, key, value) => {
16315
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
16316
- return value;
16317
- };
16306
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
16318
16307
  const _LeafletMapAdapter = class _LeafletMapAdapter {
16319
16308
  constructor() {
16320
16309
  __publicField(this, "options", { target: "map" });
@@ -16392,8 +16381,7 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
16392
16381
  }
16393
16382
  setView(lngLatOrOpt, zoom) {
16394
16383
  const map = this.map;
16395
- if (!map)
16396
- return;
16384
+ if (!map) return;
16397
16385
  if (Array.isArray(lngLatOrOpt)) {
16398
16386
  const lngLat = lngLatOrOpt;
16399
16387
  const [lng, lat] = lngLat;
@@ -16461,8 +16449,7 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
16461
16449
  return (_a = this.map && this.map.getZoom()) != null ? _a : void 0;
16462
16450
  }
16463
16451
  getBounds() {
16464
- if (!this.map)
16465
- return void 0;
16452
+ if (!this.map) return void 0;
16466
16453
  const b = this.map.getBounds();
16467
16454
  const sw = b.getSouthWest();
16468
16455
  const ne = b.getNorthEast();