@nextgis/leaflet-map-adapter 2.0.0 → 2.1.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/README.md +1 -3
- package/lib/index.d.ts +1 -0
- package/lib/leaflet-map-adapter.esm-browser.js +40 -12
- 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 +41 -13
- 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 +40 -12
- 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 +9 -8
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/** Bundle of @nextgis/leaflet-map-adapter; version: 2.
|
|
1
|
+
/** Bundle of @nextgis/leaflet-map-adapter; version: 2.1.0; author: NextGIS */
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
|
-
import { Control, DomEvent, GeoJSON, DivIcon, Marker, CircleMarker, FeatureGroup, ImageOverlay as ImageOverlay$1, Layer, Util, CRS, GridLayer, DomUtil, TileLayer as TileLayer$1, Map } from 'leaflet';
|
|
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
4
|
import { defined, debounce as debounce$1 } from '@nextgis/utils';
|
|
5
5
|
import { isPaintCallback, isPaint } from '@nextgis/paint';
|
|
6
6
|
|
|
@@ -1514,6 +1514,16 @@ class TileAdapter extends BaseAdapter {
|
|
|
1514
1514
|
}
|
|
1515
1515
|
}
|
|
1516
1516
|
}
|
|
1517
|
+
updateLayer() {
|
|
1518
|
+
if (this.layer) {
|
|
1519
|
+
const currentUrl = this.layer._url;
|
|
1520
|
+
const timestamp = (/* @__PURE__ */ new Date()).getTime();
|
|
1521
|
+
const separator = currentUrl.includes("?") ? "&" : "?";
|
|
1522
|
+
const newUrl = currentUrl.replace(/(\?|&)timestamp=\d*/g, "") + separator + `timestamp=${timestamp}`;
|
|
1523
|
+
this.layer.setUrl(newUrl);
|
|
1524
|
+
this.layer.redraw();
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1517
1527
|
}
|
|
1518
1528
|
|
|
1519
1529
|
var __defProp$2 = Object.defineProperty;
|
|
@@ -1681,6 +1691,8 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
|
|
|
1681
1691
|
center: center && [center[1], center[0]],
|
|
1682
1692
|
zoom
|
|
1683
1693
|
}, mapAdapterOptions));
|
|
1694
|
+
this._updateMinZoomForBounds(minZoom);
|
|
1695
|
+
this._watchSizeChangeToUpdateMinZoom();
|
|
1684
1696
|
const defPane = this.map.createPane("order-0");
|
|
1685
1697
|
this.map._addUnselectCb = (def) => {
|
|
1686
1698
|
this._addUnselectCb(def);
|
|
@@ -1744,19 +1756,17 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
|
|
|
1744
1756
|
if (maxBounds) {
|
|
1745
1757
|
const b = arrayToBoundsExpression(maxBounds);
|
|
1746
1758
|
map.setMaxBounds(b);
|
|
1747
|
-
|
|
1748
|
-
this._watchSizeChangeToUpdateMinZoom(b);
|
|
1759
|
+
this._updateMinZoomForBounds();
|
|
1749
1760
|
} else {
|
|
1750
1761
|
map.setMaxBounds(null);
|
|
1751
|
-
this.
|
|
1762
|
+
this._updateMinZoomForBounds();
|
|
1752
1763
|
}
|
|
1753
1764
|
}
|
|
1754
1765
|
if (maxZoom !== void 0) {
|
|
1755
1766
|
map.setMaxZoom(maxZoom);
|
|
1756
1767
|
}
|
|
1757
1768
|
if (minZoom !== void 0) {
|
|
1758
|
-
this.
|
|
1759
|
-
map.setMinZoom(minZoom);
|
|
1769
|
+
this._updateMinZoomForBounds(minZoom);
|
|
1760
1770
|
}
|
|
1761
1771
|
}
|
|
1762
1772
|
}
|
|
@@ -1890,22 +1900,18 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
|
|
|
1890
1900
|
this._unselectCb.length = 0;
|
|
1891
1901
|
this._unselectCb.push(cb);
|
|
1892
1902
|
}
|
|
1893
|
-
_watchSizeChangeToUpdateMinZoom(
|
|
1903
|
+
_watchSizeChangeToUpdateMinZoom() {
|
|
1894
1904
|
this._stopWatchSizeChangeToUpdateMinZoom();
|
|
1895
1905
|
const container = this.getContainer();
|
|
1896
1906
|
const map = this.map;
|
|
1897
1907
|
if (container && map && window.ResizeObserver) {
|
|
1898
1908
|
this._resizeObserver = new ResizeObserver(() => {
|
|
1899
|
-
|
|
1909
|
+
this._updateMinZoomForBounds();
|
|
1900
1910
|
});
|
|
1901
1911
|
this._resizeObserver.observe(container);
|
|
1902
1912
|
}
|
|
1903
1913
|
}
|
|
1904
1914
|
_stopWatchSizeChangeToUpdateMinZoom() {
|
|
1905
|
-
const map = this.map;
|
|
1906
|
-
if (map) {
|
|
1907
|
-
map.setMinZoom(0);
|
|
1908
|
-
}
|
|
1909
1915
|
if (this._resizeObserver) {
|
|
1910
1916
|
this._resizeObserver.disconnect();
|
|
1911
1917
|
this._resizeObserver = void 0;
|
|
@@ -1932,6 +1938,28 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
|
|
|
1932
1938
|
}
|
|
1933
1939
|
}
|
|
1934
1940
|
}
|
|
1941
|
+
_updateMinZoomForBounds(zoom) {
|
|
1942
|
+
var _a;
|
|
1943
|
+
const map = this.map;
|
|
1944
|
+
if (map) {
|
|
1945
|
+
zoom = zoom != null ? zoom : map.getMinZoom();
|
|
1946
|
+
const defaultBounds = latLngBounds(
|
|
1947
|
+
latLng(-90, -18e3),
|
|
1948
|
+
latLng(90, 18e3)
|
|
1949
|
+
);
|
|
1950
|
+
const maxBounds = (_a = map.options.maxBounds) != null ? _a : defaultBounds;
|
|
1951
|
+
if (maxBounds !== void 0) {
|
|
1952
|
+
map.setMinZoom(0);
|
|
1953
|
+
const boundsZoom = map.getBoundsZoom(maxBounds, true);
|
|
1954
|
+
const minZoom = zoom < boundsZoom ? boundsZoom : zoom;
|
|
1955
|
+
map.options.minZoom = minZoom;
|
|
1956
|
+
map.setMinZoom(minZoom);
|
|
1957
|
+
if (map.getZoom() < minZoom) {
|
|
1958
|
+
map.setZoom(minZoom);
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1935
1963
|
};
|
|
1936
1964
|
__publicField(_LeafletMapAdapter, "layerAdapters", {
|
|
1937
1965
|
GEOJSON: GeoJsonAdapter,
|