@nextgis/leaflet-map-adapter 2.0.2 → 2.2.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/index.d.ts +1 -0
- package/lib/leaflet-map-adapter.esm-browser.js +64 -29
- 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 +65 -30
- 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 +64 -29
- 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 +5 -5
package/lib/index.d.ts
CHANGED
|
@@ -63,6 +63,7 @@ declare class LeafletMapAdapter implements MapAdapter<Map, any, Control> {
|
|
|
63
63
|
private _watchSizeChangeToUpdateMinZoom;
|
|
64
64
|
private _stopWatchSizeChangeToUpdateMinZoom;
|
|
65
65
|
private _addMapListeners;
|
|
66
|
+
private _updateMinZoomForBounds;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
export { LeafletMapAdapter as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/leaflet-map-adapter; version: 2.0
|
|
1
|
+
/** Bundle of @nextgis/leaflet-map-adapter; version: 2.2.0; author: NextGIS */
|
|
2
2
|
var domain;
|
|
3
3
|
|
|
4
4
|
// This constructor is used to store event handlers. Instantiating this is
|
|
@@ -15685,30 +15685,32 @@ var __publicField$3 = (obj, key, value) => {
|
|
|
15685
15685
|
class ImageOverlay extends leafletSrcExports.ImageOverlay {
|
|
15686
15686
|
constructor(imageUrl, bounds, options) {
|
|
15687
15687
|
super(imageUrl, bounds, options);
|
|
15688
|
-
__publicField$3(this, "
|
|
15688
|
+
__publicField$3(this, "_aborter");
|
|
15689
15689
|
}
|
|
15690
15690
|
cancelLoad() {
|
|
15691
|
-
if (this.
|
|
15692
|
-
this.
|
|
15693
|
-
this.
|
|
15691
|
+
if (this._aborter) {
|
|
15692
|
+
this._aborter();
|
|
15693
|
+
this._aborter = void 0;
|
|
15694
15694
|
}
|
|
15695
15695
|
}
|
|
15696
15696
|
_initImage() {
|
|
15697
15697
|
super._initImage();
|
|
15698
15698
|
const headers = this.options.headers;
|
|
15699
|
+
const img = this._image;
|
|
15700
|
+
const src = img.src;
|
|
15699
15701
|
if (headers) {
|
|
15700
|
-
const img = this._image;
|
|
15701
|
-
const src = img.src;
|
|
15702
15702
|
img.src = "";
|
|
15703
|
-
this.
|
|
15704
|
-
|
|
15705
|
-
|
|
15706
|
-
|
|
15707
|
-
|
|
15708
|
-
|
|
15709
|
-
headers
|
|
15710
|
-
)
|
|
15703
|
+
this._aborter = callAjax(
|
|
15704
|
+
src,
|
|
15705
|
+
(response) => {
|
|
15706
|
+
img.src = response;
|
|
15707
|
+
},
|
|
15708
|
+
headers
|
|
15711
15709
|
);
|
|
15710
|
+
} else {
|
|
15711
|
+
this._aborter = () => {
|
|
15712
|
+
img.setAttribute("src", leafletSrcExports.Util.emptyImageUrl);
|
|
15713
|
+
};
|
|
15712
15714
|
}
|
|
15713
15715
|
}
|
|
15714
15716
|
}
|
|
@@ -15747,6 +15749,7 @@ class ImageLayer extends leafletSrcExports.Layer {
|
|
|
15747
15749
|
__publicField$2(this, "_url");
|
|
15748
15750
|
__publicField$2(this, "_currentUrl");
|
|
15749
15751
|
__publicField$2(this, "_currentOverlay");
|
|
15752
|
+
__publicField$2(this, "_loadedOverlay");
|
|
15750
15753
|
this._url = url;
|
|
15751
15754
|
const params = {};
|
|
15752
15755
|
const opts = {};
|
|
@@ -15800,15 +15803,18 @@ class ImageLayer extends leafletSrcExports.Layer {
|
|
|
15800
15803
|
this._currentUrl = url;
|
|
15801
15804
|
const viewPortBuffer = this.options.viewPortBuffer || 0;
|
|
15802
15805
|
const bounds = this._map.getBounds().pad(viewPortBuffer);
|
|
15806
|
+
if (this._loadedOverlay) {
|
|
15807
|
+
this._loadedOverlay.cancelLoad();
|
|
15808
|
+
this._loadedOverlay.off("load");
|
|
15809
|
+
this._loadedOverlay = void 0;
|
|
15810
|
+
}
|
|
15803
15811
|
const overlay = new ImageOverlay(url, bounds, {
|
|
15804
15812
|
opacity: 0,
|
|
15805
15813
|
pane: this.options.pane,
|
|
15806
15814
|
headers: this.options.headers
|
|
15807
15815
|
});
|
|
15808
15816
|
overlay.addTo(this._map);
|
|
15809
|
-
|
|
15810
|
-
this._currentOverlay.cancelLoad();
|
|
15811
|
-
}
|
|
15817
|
+
this._loadedOverlay = overlay;
|
|
15812
15818
|
overlay.once(
|
|
15813
15819
|
"load",
|
|
15814
15820
|
() => {
|
|
@@ -15821,6 +15827,7 @@ class ImageLayer extends leafletSrcExports.Layer {
|
|
|
15821
15827
|
} else if (this._currentOverlay) {
|
|
15822
15828
|
this._map.removeLayer(this._currentOverlay);
|
|
15823
15829
|
}
|
|
15830
|
+
this._loadedOverlay = void 0;
|
|
15824
15831
|
this._currentOverlay = overlay;
|
|
15825
15832
|
overlay.setOpacity(
|
|
15826
15833
|
this.options.opacity !== void 0 ? this.options.opacity : 1
|
|
@@ -16066,6 +16073,16 @@ class TileAdapter extends BaseAdapter {
|
|
|
16066
16073
|
}
|
|
16067
16074
|
}
|
|
16068
16075
|
}
|
|
16076
|
+
updateLayer() {
|
|
16077
|
+
if (this.layer) {
|
|
16078
|
+
const currentUrl = this.layer._url;
|
|
16079
|
+
const timestamp = (/* @__PURE__ */ new Date()).getTime();
|
|
16080
|
+
const separator = currentUrl.includes("?") ? "&" : "?";
|
|
16081
|
+
const newUrl = currentUrl.replace(/(\?|&)timestamp=\d*/g, "") + separator + `timestamp=${timestamp}`;
|
|
16082
|
+
this.layer.setUrl(newUrl);
|
|
16083
|
+
this.layer.redraw();
|
|
16084
|
+
}
|
|
16085
|
+
}
|
|
16069
16086
|
}
|
|
16070
16087
|
|
|
16071
16088
|
var __defProp$2 = Object.defineProperty;
|
|
@@ -16233,6 +16250,8 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
|
|
|
16233
16250
|
center: center && [center[1], center[0]],
|
|
16234
16251
|
zoom
|
|
16235
16252
|
}, mapAdapterOptions));
|
|
16253
|
+
this._updateMinZoomForBounds(minZoom);
|
|
16254
|
+
this._watchSizeChangeToUpdateMinZoom();
|
|
16236
16255
|
const defPane = this.map.createPane("order-0");
|
|
16237
16256
|
this.map._addUnselectCb = (def) => {
|
|
16238
16257
|
this._addUnselectCb(def);
|
|
@@ -16296,19 +16315,17 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
|
|
|
16296
16315
|
if (maxBounds) {
|
|
16297
16316
|
const b = arrayToBoundsExpression(maxBounds);
|
|
16298
16317
|
map.setMaxBounds(b);
|
|
16299
|
-
|
|
16300
|
-
this._watchSizeChangeToUpdateMinZoom(b);
|
|
16318
|
+
this._updateMinZoomForBounds();
|
|
16301
16319
|
} else {
|
|
16302
16320
|
map.setMaxBounds(null);
|
|
16303
|
-
this.
|
|
16321
|
+
this._updateMinZoomForBounds();
|
|
16304
16322
|
}
|
|
16305
16323
|
}
|
|
16306
16324
|
if (maxZoom !== void 0) {
|
|
16307
16325
|
map.setMaxZoom(maxZoom);
|
|
16308
16326
|
}
|
|
16309
16327
|
if (minZoom !== void 0) {
|
|
16310
|
-
this.
|
|
16311
|
-
map.setMinZoom(minZoom);
|
|
16328
|
+
this._updateMinZoomForBounds(minZoom);
|
|
16312
16329
|
}
|
|
16313
16330
|
}
|
|
16314
16331
|
}
|
|
@@ -16442,22 +16459,18 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
|
|
|
16442
16459
|
this._unselectCb.length = 0;
|
|
16443
16460
|
this._unselectCb.push(cb);
|
|
16444
16461
|
}
|
|
16445
|
-
_watchSizeChangeToUpdateMinZoom(
|
|
16462
|
+
_watchSizeChangeToUpdateMinZoom() {
|
|
16446
16463
|
this._stopWatchSizeChangeToUpdateMinZoom();
|
|
16447
16464
|
const container = this.getContainer();
|
|
16448
16465
|
const map = this.map;
|
|
16449
16466
|
if (container && map && window.ResizeObserver) {
|
|
16450
16467
|
this._resizeObserver = new ResizeObserver(() => {
|
|
16451
|
-
|
|
16468
|
+
this._updateMinZoomForBounds();
|
|
16452
16469
|
});
|
|
16453
16470
|
this._resizeObserver.observe(container);
|
|
16454
16471
|
}
|
|
16455
16472
|
}
|
|
16456
16473
|
_stopWatchSizeChangeToUpdateMinZoom() {
|
|
16457
|
-
const map = this.map;
|
|
16458
|
-
if (map) {
|
|
16459
|
-
map.setMinZoom(0);
|
|
16460
|
-
}
|
|
16461
16474
|
if (this._resizeObserver) {
|
|
16462
16475
|
this._resizeObserver.disconnect();
|
|
16463
16476
|
this._resizeObserver = void 0;
|
|
@@ -16484,6 +16497,28 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
|
|
|
16484
16497
|
}
|
|
16485
16498
|
}
|
|
16486
16499
|
}
|
|
16500
|
+
_updateMinZoomForBounds(zoom) {
|
|
16501
|
+
var _a;
|
|
16502
|
+
const map = this.map;
|
|
16503
|
+
if (map) {
|
|
16504
|
+
zoom = zoom != null ? zoom : map.getMinZoom();
|
|
16505
|
+
const defaultBounds = leafletSrcExports.latLngBounds(
|
|
16506
|
+
leafletSrcExports.latLng(-90, -18e3),
|
|
16507
|
+
leafletSrcExports.latLng(90, 18e3)
|
|
16508
|
+
);
|
|
16509
|
+
const maxBounds = (_a = map.options.maxBounds) != null ? _a : defaultBounds;
|
|
16510
|
+
if (maxBounds !== void 0) {
|
|
16511
|
+
map.setMinZoom(0);
|
|
16512
|
+
const boundsZoom = map.getBoundsZoom(maxBounds, true);
|
|
16513
|
+
const minZoom = zoom < boundsZoom ? boundsZoom : zoom;
|
|
16514
|
+
map.options.minZoom = minZoom;
|
|
16515
|
+
map.setMinZoom(minZoom);
|
|
16516
|
+
if (map.getZoom() < minZoom) {
|
|
16517
|
+
map.setZoom(minZoom);
|
|
16518
|
+
}
|
|
16519
|
+
}
|
|
16520
|
+
}
|
|
16521
|
+
}
|
|
16487
16522
|
};
|
|
16488
16523
|
__publicField(_LeafletMapAdapter, "layerAdapters", {
|
|
16489
16524
|
GEOJSON: GeoJsonAdapter,
|