@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.
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/leaflet-map-adapter; version: 2.3.0; author: NextGIS */
1
+ /** Bundle of @nextgis/leaflet-map-adapter; version: 2.5.0; author: NextGIS */
2
2
  var LeafletMapAdapter = (function () {
3
3
  'use strict';
4
4
 
@@ -14951,7 +14951,7 @@ var LeafletMapAdapter = (function () {
14951
14951
  }
14952
14952
  return target;
14953
14953
  };
14954
- var __publicField$6 = (obj, key, value) => __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
14954
+ var __publicField$6 = (obj, key, value) => __defNormalProp$9(obj, key + "" , value);
14955
14955
  class GeoJsonPaint {
14956
14956
  constructor(layer) {
14957
14957
  __publicField$6(this, "layer");
@@ -15658,7 +15658,11 @@ var LeafletMapAdapter = (function () {
15658
15658
  }
15659
15659
  }
15660
15660
 
15661
- function callAjax(src, headers) {
15661
+ function callAjax({
15662
+ src,
15663
+ headers,
15664
+ withCredentials
15665
+ }) {
15662
15666
  let abortFunc = () => {
15663
15667
  };
15664
15668
  const promise = new Promise((resolve, reject) => {
@@ -15668,6 +15672,9 @@ var LeafletMapAdapter = (function () {
15668
15672
  for (const h in headers) {
15669
15673
  xhr.setRequestHeader(h, headers[h]);
15670
15674
  }
15675
+ if (withCredentials) {
15676
+ xhr.withCredentials = withCredentials;
15677
+ }
15671
15678
  xhr.onload = function() {
15672
15679
  const arrayBufferView = new Uint8Array(this.response);
15673
15680
  const blob = new Blob([arrayBufferView], { type: "image/png" });
@@ -15776,7 +15783,7 @@ var LeafletMapAdapter = (function () {
15776
15783
 
15777
15784
  var __defProp$6 = Object.defineProperty;
15778
15785
  var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15779
- var __publicField$3 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
15786
+ var __publicField$3 = (obj, key, value) => __defNormalProp$6(obj, key + "" , value);
15780
15787
  class ImageOverlay extends leafletSrcExports.ImageOverlay {
15781
15788
  constructor(imageUrl, bounds, options) {
15782
15789
  super(imageUrl, bounds, options);
@@ -15790,12 +15797,16 @@ var LeafletMapAdapter = (function () {
15790
15797
  }
15791
15798
  _initImage() {
15792
15799
  super._initImage();
15793
- const headers = this.options.headers;
15800
+ const { headers, withCredentials } = this.options;
15794
15801
  const img = this._image;
15795
15802
  const src = img.src;
15796
15803
  img.src = "";
15797
15804
  imageQueue.add(() => {
15798
- const [promise, abortFunc] = callAjax(src, headers);
15805
+ const [promise, abortFunc] = callAjax({
15806
+ src,
15807
+ headers,
15808
+ withCredentials
15809
+ });
15799
15810
  promise.then((imgUrl) => {
15800
15811
  img.src = imgUrl;
15801
15812
  });
@@ -15829,6 +15840,7 @@ var LeafletMapAdapter = (function () {
15829
15840
  minZoom: 0,
15830
15841
  pane: "tilePane",
15831
15842
  headers: null,
15843
+ withCredentials: false,
15832
15844
  viewPortBuffer: 0,
15833
15845
  setViewDelay: 100
15834
15846
  });
@@ -15898,7 +15910,8 @@ var LeafletMapAdapter = (function () {
15898
15910
  const overlay = new ImageOverlay(url, bounds, {
15899
15911
  opacity: 0,
15900
15912
  pane: this.options.pane,
15901
- headers: this.options.headers
15913
+ headers: this.options.headers,
15914
+ withCredentials: this.options.withCredentials
15902
15915
  });
15903
15916
  overlay.addTo(this._map);
15904
15917
  this._loadedOverlay = overlay;
@@ -16051,13 +16064,13 @@ var LeafletMapAdapter = (function () {
16051
16064
  }
16052
16065
  }
16053
16066
  createTile(coords, done) {
16054
- const url = this.getTileUrl(coords);
16067
+ const src = this.getTileUrl(coords);
16055
16068
  const tile = document.createElement("img");
16056
- const [promise, abortFunc] = callAjax(
16057
- url,
16058
- // @ts-ignore
16059
- this.options.headers
16060
- );
16069
+ const [promise, abortFunc] = callAjax({
16070
+ src,
16071
+ withCredentials: this.options.withCredentials,
16072
+ headers: this.options.headers
16073
+ });
16061
16074
  promise.then((response) => {
16062
16075
  tile.src = response;
16063
16076
  done(null, tile);
@@ -16147,9 +16160,10 @@ var LeafletMapAdapter = (function () {
16147
16160
  tileLayerOptions.subdomains = opt.subdomains;
16148
16161
  }
16149
16162
  let layer;
16150
- if (opt.headers) {
16163
+ if (opt.headers || opt.withCredentials) {
16151
16164
  layer = new TileLayer(url, __spreadProps$2(__spreadValues$3({}, tileLayerOptions), {
16152
16165
  headers: opt.headers,
16166
+ withCredentials: opt.withCredentials,
16153
16167
  setViewDelay: opt.setViewDelay
16154
16168
  }));
16155
16169
  } else {
@@ -16255,8 +16269,11 @@ var LeafletMapAdapter = (function () {
16255
16269
  transparent: true
16256
16270
  }, options.nativeOptions);
16257
16271
  let layer;
16258
- if (opt.headers) {
16259
- layer = new WmsLayer(url, __spreadProps(__spreadValues$1({}, layerOptions), { headers: opt.headers }));
16272
+ if (opt.headers || opt.withCredentials) {
16273
+ layer = new WmsLayer(url, __spreadProps(__spreadValues$1({}, layerOptions), {
16274
+ headers: opt.headers,
16275
+ withCredentials: opt.withCredentials
16276
+ }));
16260
16277
  } else {
16261
16278
  layer = new leafletSrcExports.TileLayer.WMS(url, layerOptions);
16262
16279
  }