@nextgis/leaflet-map-adapter 3.0.0 → 4.0.0-alpha.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 +4 -2
- package/lib/leaflet-map-adapter.css +1 -0
- package/lib/leaflet-map-adapter.esm-browser.js +1718 -1004
- package/lib/leaflet-map-adapter.esm-browser.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-browser.prod.js +2 -2
- package/lib/leaflet-map-adapter.esm-browser.prod.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-bundler.js +20 -84
- 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 +1718 -1004
- package/lib/leaflet-map-adapter.global.js.map +1 -1
- package/lib/leaflet-map-adapter.global.prod.js +2 -2
- package/lib/leaflet-map-adapter.global.prod.js.map +1 -1
- package/package.json +4 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
/** Bundle of @nextgis/leaflet-map-adapter; version:
|
|
1
|
+
/** Bundle of @nextgis/leaflet-map-adapter; version: 4.0.0-alpha.0; author: NextGIS */
|
|
2
|
+
import { LeafletControlContainer, createControl, createButtonControl, createToggleControl } from '@nextgis/leaflet-control-container';
|
|
2
3
|
import { EventEmitter } from 'events';
|
|
3
|
-
import { Control,
|
|
4
|
+
import { Control, GeoJSON, DomEvent, DivIcon, Marker, CircleMarker, FeatureGroup, ImageOverlay as ImageOverlay$1, Layer, Util, GridLayer, DomUtil, TileLayer as TileLayer$1, Map, latLngBounds, latLng } from 'leaflet';
|
|
4
5
|
import { defined, debounce as debounce$1, isObject, updateUrlParams } from '@nextgis/utils';
|
|
5
6
|
import { isPaintCallback, isPaint } from '@nextgis/paint';
|
|
6
7
|
import Queue from '@nextgis/queue';
|
|
@@ -22,81 +23,6 @@ class AttributionControl extends Control.Attribution {
|
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
function createControl(control, options = {}, map) {
|
|
26
|
-
const C = Control.extend({
|
|
27
|
-
onAdd() {
|
|
28
|
-
const element = document.createElement("div");
|
|
29
|
-
const content = control.onAdd(map);
|
|
30
|
-
element.classList.add("leaflet-control");
|
|
31
|
-
if (options.bar) {
|
|
32
|
-
element.classList.add("leaflet-bar");
|
|
33
|
-
}
|
|
34
|
-
if (options.addClass) {
|
|
35
|
-
element.classList.add(options.addClass);
|
|
36
|
-
}
|
|
37
|
-
if (!options.margin && !options.bar) {
|
|
38
|
-
element.style.marginBottom = "0px";
|
|
39
|
-
element.style.marginTop = "0px";
|
|
40
|
-
element.style.marginLeft = "0px";
|
|
41
|
-
element.style.marginRight = "0px";
|
|
42
|
-
}
|
|
43
|
-
if (content) {
|
|
44
|
-
element.appendChild(content);
|
|
45
|
-
}
|
|
46
|
-
DomEvent.disableClickPropagation(element);
|
|
47
|
-
return element;
|
|
48
|
-
},
|
|
49
|
-
onRemove() {
|
|
50
|
-
control.onRemove();
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
return new C();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function createButtonControl(options, map) {
|
|
57
|
-
const link = document.createElement("a");
|
|
58
|
-
const title = options.title || "";
|
|
59
|
-
link.href = "#";
|
|
60
|
-
link.title = title;
|
|
61
|
-
link.setAttribute("role", "button");
|
|
62
|
-
link.setAttribute("aria-label", title);
|
|
63
|
-
if (options.addClass) {
|
|
64
|
-
link.classList.add(options.addClass);
|
|
65
|
-
}
|
|
66
|
-
DomEvent.disableClickPropagation(link);
|
|
67
|
-
DomEvent.on(link, "click", DomEvent.stop);
|
|
68
|
-
if (options.html instanceof HTMLElement) {
|
|
69
|
-
link.appendChild(options.html);
|
|
70
|
-
} else if (typeof options.html === "string") {
|
|
71
|
-
link.innerHTML = options.html;
|
|
72
|
-
}
|
|
73
|
-
const onClick = (e) => {
|
|
74
|
-
e.stopPropagation();
|
|
75
|
-
options.onClick();
|
|
76
|
-
};
|
|
77
|
-
return createControl(
|
|
78
|
-
{
|
|
79
|
-
onAdd() {
|
|
80
|
-
if (options.onClick !== void 0) {
|
|
81
|
-
link.addEventListener("click", onClick);
|
|
82
|
-
}
|
|
83
|
-
return link;
|
|
84
|
-
},
|
|
85
|
-
onRemove() {
|
|
86
|
-
const parent = link.parentNode;
|
|
87
|
-
if (parent) {
|
|
88
|
-
parent.removeChild(link);
|
|
89
|
-
}
|
|
90
|
-
if (options.onClick !== void 0) {
|
|
91
|
-
link.removeEventListener("click", onClick);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
{ bar: true },
|
|
96
|
-
map
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
26
|
function boundsToArray(bounds) {
|
|
101
27
|
const ne = bounds.getNorthEast();
|
|
102
28
|
const sw = bounds.getSouthWest();
|
|
@@ -1688,6 +1614,7 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
|
|
|
1688
1614
|
__publicField(this, "emitter", new EventEmitter());
|
|
1689
1615
|
__publicField(this, "map");
|
|
1690
1616
|
__publicField(this, "_resizeObserver");
|
|
1617
|
+
__publicField(this, "_controlContainer");
|
|
1691
1618
|
__publicField(this, "_unselectCb", []);
|
|
1692
1619
|
__publicField(this, "_universalEvents", [
|
|
1693
1620
|
"move",
|
|
@@ -1726,6 +1653,7 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
|
|
|
1726
1653
|
this._updateMinZoomForBounds(minZoom);
|
|
1727
1654
|
this._watchSizeChangeToUpdateMinZoom();
|
|
1728
1655
|
const defPane = this.map.createPane("order-0");
|
|
1656
|
+
this._controlContainer = new LeafletControlContainer(this.map);
|
|
1729
1657
|
this.map._addUnselectCb = (def) => {
|
|
1730
1658
|
this._addUnselectCb(def);
|
|
1731
1659
|
};
|
|
@@ -1738,12 +1666,19 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
|
|
|
1738
1666
|
if (this.map) {
|
|
1739
1667
|
this.map.remove();
|
|
1740
1668
|
}
|
|
1669
|
+
if (this._controlContainer) {
|
|
1670
|
+
this._controlContainer.detach();
|
|
1671
|
+
this._controlContainer = void 0;
|
|
1672
|
+
}
|
|
1741
1673
|
this._stopWatchSizeChangeToUpdateMinZoom();
|
|
1742
1674
|
}
|
|
1743
1675
|
getContainer() {
|
|
1744
1676
|
return this.map && this.map.getContainer();
|
|
1745
1677
|
}
|
|
1746
1678
|
getControlContainer() {
|
|
1679
|
+
if (this._controlContainer) {
|
|
1680
|
+
return this._controlContainer.getContainer();
|
|
1681
|
+
}
|
|
1747
1682
|
const controlContainer = this.map && this.map._controlContainer;
|
|
1748
1683
|
if (controlContainer) {
|
|
1749
1684
|
return controlContainer;
|
|
@@ -1857,16 +1792,17 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
|
|
|
1857
1792
|
createButtonControl(options) {
|
|
1858
1793
|
return createButtonControl(options, this);
|
|
1859
1794
|
}
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1795
|
+
createToggleControl(options) {
|
|
1796
|
+
return createToggleControl(options, this);
|
|
1797
|
+
}
|
|
1798
|
+
addControl(control, position, options) {
|
|
1799
|
+
if (this._controlContainer) {
|
|
1800
|
+
return this._controlContainer.addControl(control, position, options);
|
|
1865
1801
|
}
|
|
1866
1802
|
}
|
|
1867
1803
|
removeControl(control) {
|
|
1868
|
-
if (this.
|
|
1869
|
-
this.
|
|
1804
|
+
if (this._controlContainer) {
|
|
1805
|
+
this._controlContainer.removeControl(control);
|
|
1870
1806
|
}
|
|
1871
1807
|
}
|
|
1872
1808
|
removeLayer(layer) {
|