leaflet-polydraw 2.1.0 → 2.1.1
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 +8 -22
- package/dist/leaflet-polydraw.css +1 -1
- package/dist/polydraw.es.js +267 -183
- package/dist/polydraw.es.js.map +1 -1
- package/dist/polydraw.umd.min.js +1 -1
- package/dist/polydraw.umd.min.js.map +1 -1
- package/dist/styles/polydraw.css +5 -1
- package/dist/types/buttons.d.ts.map +1 -1
- package/dist/types/compatibility/leaflet-adapter.d.ts +2 -2
- package/dist/types/compatibility/leaflet-adapter.d.ts.map +1 -1
- package/dist/types/compatibility/version-detector.d.ts.map +1 -1
- package/dist/types/coordinate-utils.d.ts.map +1 -1
- package/dist/types/geometry-utils.d.ts +5 -0
- package/dist/types/geometry-utils.d.ts.map +1 -1
- package/dist/types/managers/event-manager.d.ts +3 -1
- package/dist/types/managers/event-manager.d.ts.map +1 -1
- package/dist/types/managers/polygon-draw-manager.d.ts +4 -4
- package/dist/types/managers/polygon-draw-manager.d.ts.map +1 -1
- package/dist/types/managers/polygon-interaction-manager.d.ts +1 -0
- package/dist/types/managers/polygon-interaction-manager.d.ts.map +1 -1
- package/dist/types/managers/polygon-mutation-manager.d.ts +4 -4
- package/dist/types/managers/polygon-mutation-manager.d.ts.map +1 -1
- package/dist/types/polydraw.d.ts +7 -0
- package/dist/types/polydraw.d.ts.map +1 -1
- package/dist/types/types/polydraw-interfaces.d.ts +8 -1
- package/dist/types/types/polydraw-interfaces.d.ts.map +1 -1
- package/dist/types/ui/layer-panel.d.ts.map +1 -1
- package/package.json +4 -3
package/dist/polydraw.es.js
CHANGED
|
@@ -9726,6 +9726,14 @@ const getGlobalLeaflet = () => {
|
|
|
9726
9726
|
if (typeof globalThis === "undefined") return void 0;
|
|
9727
9727
|
return globalThis.L;
|
|
9728
9728
|
};
|
|
9729
|
+
const getModuleLeaflet = () => ({
|
|
9730
|
+
version: Reflect.get(L, "version"),
|
|
9731
|
+
marker: Reflect.get(L, "marker"),
|
|
9732
|
+
polyline: Reflect.get(L, "polyline"),
|
|
9733
|
+
polygon: Reflect.get(L, "polygon"),
|
|
9734
|
+
Marker: Reflect.get(L, "Marker"),
|
|
9735
|
+
Polyline: Reflect.get(L, "Polyline")
|
|
9736
|
+
});
|
|
9729
9737
|
class LeafletVersionDetector {
|
|
9730
9738
|
/**
|
|
9731
9739
|
* Detects the Leaflet version being used
|
|
@@ -9735,11 +9743,7 @@ class LeafletVersionDetector {
|
|
|
9735
9743
|
if (this._detectedVersion) {
|
|
9736
9744
|
return this._detectedVersion;
|
|
9737
9745
|
}
|
|
9738
|
-
|
|
9739
|
-
if (!globalL) {
|
|
9740
|
-
return LeafletVersion.V2;
|
|
9741
|
-
}
|
|
9742
|
-
this._detectedVersion = this.detectVersion(globalL);
|
|
9746
|
+
this._detectedVersion = this.detectVersion(getGlobalLeaflet() ?? getModuleLeaflet());
|
|
9743
9747
|
return this._detectedVersion;
|
|
9744
9748
|
}
|
|
9745
9749
|
/**
|
|
@@ -9747,10 +9751,7 @@ class LeafletVersionDetector {
|
|
|
9747
9751
|
* @returns The detected Leaflet version
|
|
9748
9752
|
*/
|
|
9749
9753
|
static detectVersion(globalL) {
|
|
9750
|
-
const resolvedGlobal = globalL ?? getGlobalLeaflet();
|
|
9751
|
-
if (!resolvedGlobal) {
|
|
9752
|
-
return LeafletVersion.V2;
|
|
9753
|
-
}
|
|
9754
|
+
const resolvedGlobal = globalL ?? getGlobalLeaflet() ?? getModuleLeaflet();
|
|
9754
9755
|
if (resolvedGlobal.version) {
|
|
9755
9756
|
if (resolvedGlobal.version.startsWith("2.")) {
|
|
9756
9757
|
return LeafletVersion.V2;
|
|
@@ -9797,16 +9798,19 @@ class LeafletVersionDetector {
|
|
|
9797
9798
|
static getVersionInfo() {
|
|
9798
9799
|
const version = this.getVersion();
|
|
9799
9800
|
const globalL = getGlobalLeaflet();
|
|
9801
|
+
const resolvedLeaflet = globalL ?? getModuleLeaflet();
|
|
9800
9802
|
return {
|
|
9801
9803
|
version,
|
|
9802
|
-
leafletVersion:
|
|
9803
|
-
hasFactoryMethods: typeof
|
|
9804
|
-
hasConstructors: !!
|
|
9804
|
+
leafletVersion: resolvedLeaflet.version,
|
|
9805
|
+
hasFactoryMethods: typeof resolvedLeaflet.marker === "function",
|
|
9806
|
+
hasConstructors: !!resolvedLeaflet.Marker && typeof resolvedLeaflet.Marker === "function",
|
|
9805
9807
|
globalLAvailable: !!globalL
|
|
9806
9808
|
};
|
|
9807
9809
|
}
|
|
9808
9810
|
}
|
|
9809
9811
|
__publicField(LeafletVersionDetector, "_detectedVersion", null);
|
|
9812
|
+
const getLegacyBrowser = () => Reflect.get(L, "Browser") ?? {};
|
|
9813
|
+
const getNavigator = () => typeof navigator === "undefined" ? void 0 : navigator;
|
|
9810
9814
|
class LeafletAdapter {
|
|
9811
9815
|
constructor() {
|
|
9812
9816
|
/**
|
|
@@ -9828,25 +9832,13 @@ class LeafletAdapter {
|
|
|
9828
9832
|
}
|
|
9829
9833
|
},
|
|
9830
9834
|
addClass: (el, name) => {
|
|
9831
|
-
|
|
9832
|
-
L.DomUtil.addClass(el, name);
|
|
9833
|
-
} else {
|
|
9834
|
-
el.classList.add(name);
|
|
9835
|
-
}
|
|
9835
|
+
el.classList.add(name);
|
|
9836
9836
|
},
|
|
9837
9837
|
removeClass: (el, name) => {
|
|
9838
|
-
|
|
9839
|
-
L.DomUtil.removeClass(el, name);
|
|
9840
|
-
} else {
|
|
9841
|
-
el.classList.remove(name);
|
|
9842
|
-
}
|
|
9838
|
+
el.classList.remove(name);
|
|
9843
9839
|
},
|
|
9844
9840
|
hasClass: (el, name) => {
|
|
9845
|
-
|
|
9846
|
-
return L.DomUtil.hasClass(el, name);
|
|
9847
|
-
} else {
|
|
9848
|
-
return el.classList.contains(name);
|
|
9849
|
-
}
|
|
9841
|
+
return el.classList.contains(name);
|
|
9850
9842
|
},
|
|
9851
9843
|
setPosition: (el, point2) => {
|
|
9852
9844
|
L.DomUtil.setPosition(el, point2);
|
|
@@ -9868,7 +9860,8 @@ class LeafletAdapter {
|
|
|
9868
9860
|
return this;
|
|
9869
9861
|
},
|
|
9870
9862
|
stopPropagation: (e) => {
|
|
9871
|
-
L.DomEvent.stopPropagation
|
|
9863
|
+
const stopPropagation = L.DomEvent.stopPropagation;
|
|
9864
|
+
stopPropagation(e);
|
|
9872
9865
|
return this;
|
|
9873
9866
|
},
|
|
9874
9867
|
preventDefault: (e) => {
|
|
@@ -9888,12 +9881,8 @@ class LeafletAdapter {
|
|
|
9888
9881
|
return this;
|
|
9889
9882
|
},
|
|
9890
9883
|
getMousePosition: (e, container) => {
|
|
9891
|
-
|
|
9892
|
-
|
|
9893
|
-
} else {
|
|
9894
|
-
const domEvent = L.DomEvent;
|
|
9895
|
-
return domEvent.getPointerPosition ? domEvent.getPointerPosition(e, container) : L.DomEvent.getMousePosition(e, container);
|
|
9896
|
-
}
|
|
9884
|
+
const rect = container == null ? void 0 : container.getBoundingClientRect();
|
|
9885
|
+
return new L.Point(e.clientX - ((rect == null ? void 0 : rect.left) ?? 0), e.clientY - ((rect == null ? void 0 : rect.top) ?? 0));
|
|
9897
9886
|
}
|
|
9898
9887
|
});
|
|
9899
9888
|
/**
|
|
@@ -9901,18 +9890,10 @@ class LeafletAdapter {
|
|
|
9901
9890
|
*/
|
|
9902
9891
|
__publicField(this, "util", {
|
|
9903
9892
|
extend: (dest, ...sources) => {
|
|
9904
|
-
|
|
9905
|
-
return L.Util.extend(dest, ...sources);
|
|
9906
|
-
} else {
|
|
9907
|
-
return Object.assign(dest, ...sources);
|
|
9908
|
-
}
|
|
9893
|
+
return Object.assign(dest, ...sources);
|
|
9909
9894
|
},
|
|
9910
9895
|
bind: (fn, obj) => {
|
|
9911
|
-
|
|
9912
|
-
return L.Util.bind(fn, obj);
|
|
9913
|
-
} else {
|
|
9914
|
-
return fn.bind(obj);
|
|
9915
|
-
}
|
|
9896
|
+
return fn.bind(obj);
|
|
9916
9897
|
},
|
|
9917
9898
|
stamp: (obj) => {
|
|
9918
9899
|
return L.Util.stamp(obj);
|
|
@@ -9930,11 +9911,7 @@ class LeafletAdapter {
|
|
|
9930
9911
|
return L.Util.formatNum(num, digits);
|
|
9931
9912
|
},
|
|
9932
9913
|
trim: (str) => {
|
|
9933
|
-
|
|
9934
|
-
return L.Util.trim(str);
|
|
9935
|
-
} else {
|
|
9936
|
-
return str.trim();
|
|
9937
|
-
}
|
|
9914
|
+
return str.trim();
|
|
9938
9915
|
},
|
|
9939
9916
|
splitWords: (str) => {
|
|
9940
9917
|
return L.Util.splitWords(str);
|
|
@@ -9943,50 +9920,34 @@ class LeafletAdapter {
|
|
|
9943
9920
|
return L.Util.setOptions(obj, options);
|
|
9944
9921
|
},
|
|
9945
9922
|
getParamString: (obj, existingUrl, uppercase) => {
|
|
9946
|
-
|
|
9947
|
-
|
|
9948
|
-
|
|
9949
|
-
|
|
9950
|
-
|
|
9951
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
9952
|
-
const paramKey = uppercase ? key.toUpperCase() : key;
|
|
9953
|
-
params.set(paramKey, String(obj[key]));
|
|
9954
|
-
}
|
|
9955
|
-
}
|
|
9956
|
-
const paramString = params.toString();
|
|
9957
|
-
if (existingUrl) {
|
|
9958
|
-
const separator = existingUrl.indexOf("?") === -1 ? "?" : "&";
|
|
9959
|
-
return existingUrl + separator + paramString;
|
|
9923
|
+
const params = new URLSearchParams();
|
|
9924
|
+
for (const key in obj) {
|
|
9925
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
9926
|
+
const paramKey = uppercase ? key.toUpperCase() : key;
|
|
9927
|
+
params.set(paramKey, String(obj[key]));
|
|
9960
9928
|
}
|
|
9961
|
-
return paramString ? "?" + paramString : "";
|
|
9962
9929
|
}
|
|
9930
|
+
const paramString = params.toString();
|
|
9931
|
+
if (existingUrl) {
|
|
9932
|
+
const separator = existingUrl.indexOf("?") === -1 ? "?" : "&";
|
|
9933
|
+
return existingUrl + separator + paramString;
|
|
9934
|
+
}
|
|
9935
|
+
return paramString ? "?" + paramString : "";
|
|
9963
9936
|
},
|
|
9964
9937
|
template: (str, data) => {
|
|
9965
9938
|
return L.Util.template(str, data);
|
|
9966
9939
|
},
|
|
9967
9940
|
isArray: (obj) => {
|
|
9968
|
-
|
|
9969
|
-
return L.Util.isArray(obj);
|
|
9970
|
-
} else {
|
|
9971
|
-
return Array.isArray(obj);
|
|
9972
|
-
}
|
|
9941
|
+
return Array.isArray(obj);
|
|
9973
9942
|
},
|
|
9974
9943
|
indexOf: (array, item) => {
|
|
9975
|
-
return
|
|
9944
|
+
return array.indexOf(item);
|
|
9976
9945
|
},
|
|
9977
9946
|
requestAnimFrame: (fn, context, immediate) => {
|
|
9978
|
-
|
|
9979
|
-
return L.Util.requestAnimFrame(fn, context, immediate);
|
|
9980
|
-
} else {
|
|
9981
|
-
return requestAnimationFrame(context ? fn.bind(context) : fn);
|
|
9982
|
-
}
|
|
9947
|
+
return requestAnimationFrame(context ? fn.bind(context) : fn);
|
|
9983
9948
|
},
|
|
9984
9949
|
cancelAnimFrame: (id) => {
|
|
9985
|
-
|
|
9986
|
-
L.Util.cancelAnimFrame(id);
|
|
9987
|
-
} else {
|
|
9988
|
-
cancelAnimationFrame(id);
|
|
9989
|
-
}
|
|
9950
|
+
cancelAnimationFrame(id);
|
|
9990
9951
|
}
|
|
9991
9952
|
});
|
|
9992
9953
|
}
|
|
@@ -10075,107 +10036,110 @@ class LeafletAdapter {
|
|
|
10075
10036
|
* Browser detection compatibility
|
|
10076
10037
|
*/
|
|
10077
10038
|
getBrowser() {
|
|
10078
|
-
const
|
|
10079
|
-
const
|
|
10039
|
+
const browser = getLegacyBrowser();
|
|
10040
|
+
const currentNavigator = getNavigator();
|
|
10041
|
+
const userAgent = (currentNavigator == null ? void 0 : currentNavigator.userAgent) ?? "";
|
|
10042
|
+
const platform = (currentNavigator == null ? void 0 : currentNavigator.platform) ?? "";
|
|
10043
|
+
const coarsePointer = typeof matchMedia !== "undefined" && matchMedia("(pointer: coarse)").matches;
|
|
10080
10044
|
return {
|
|
10081
10045
|
get ie() {
|
|
10082
|
-
return
|
|
10046
|
+
return browser.ie ?? false;
|
|
10083
10047
|
},
|
|
10084
10048
|
get ielt9() {
|
|
10085
|
-
return
|
|
10049
|
+
return browser.ielt9 ?? false;
|
|
10086
10050
|
},
|
|
10087
10051
|
get edge() {
|
|
10088
|
-
return
|
|
10052
|
+
return browser.edge ?? false;
|
|
10089
10053
|
},
|
|
10090
10054
|
get webkit() {
|
|
10091
|
-
return
|
|
10055
|
+
return browser.webkit ?? /AppleWebKit/.test(userAgent);
|
|
10092
10056
|
},
|
|
10093
10057
|
get android() {
|
|
10094
|
-
return
|
|
10058
|
+
return browser.android ?? /Android/.test(userAgent);
|
|
10095
10059
|
},
|
|
10096
10060
|
get android23() {
|
|
10097
|
-
return
|
|
10061
|
+
return browser.android23 ?? false;
|
|
10098
10062
|
},
|
|
10099
10063
|
get androidStock() {
|
|
10100
|
-
return
|
|
10064
|
+
return browser.androidStock ?? false;
|
|
10101
10065
|
},
|
|
10102
10066
|
get opera() {
|
|
10103
|
-
return
|
|
10067
|
+
return browser.opera ?? false;
|
|
10104
10068
|
},
|
|
10105
10069
|
get chrome() {
|
|
10106
|
-
return
|
|
10070
|
+
return browser.chrome ?? /(?:Chrome|CriOS)/.test(userAgent);
|
|
10107
10071
|
},
|
|
10108
10072
|
get gecko() {
|
|
10109
|
-
return
|
|
10073
|
+
return browser.gecko ?? /Gecko\//.test(userAgent);
|
|
10110
10074
|
},
|
|
10111
10075
|
get safari() {
|
|
10112
|
-
return
|
|
10076
|
+
return browser.safari ?? (/Safari/.test(userAgent) && !/(?:Chrome|CriOS)/.test(userAgent));
|
|
10113
10077
|
},
|
|
10114
10078
|
get phantom() {
|
|
10115
|
-
return
|
|
10079
|
+
return browser.phantom ?? false;
|
|
10116
10080
|
},
|
|
10117
10081
|
get opera12() {
|
|
10118
|
-
return
|
|
10082
|
+
return browser.opera12 ?? false;
|
|
10119
10083
|
},
|
|
10120
10084
|
get win() {
|
|
10121
|
-
return
|
|
10085
|
+
return browser.win ?? /Win/.test(platform);
|
|
10122
10086
|
},
|
|
10123
10087
|
get ie3d() {
|
|
10124
|
-
return
|
|
10088
|
+
return browser.ie3d ?? false;
|
|
10125
10089
|
},
|
|
10126
10090
|
get webkit3d() {
|
|
10127
|
-
return
|
|
10091
|
+
return browser.webkit3d ?? false;
|
|
10128
10092
|
},
|
|
10129
10093
|
get gecko3d() {
|
|
10130
|
-
return
|
|
10094
|
+
return browser.gecko3d ?? false;
|
|
10131
10095
|
},
|
|
10132
10096
|
get any3d() {
|
|
10133
|
-
return
|
|
10097
|
+
return browser.any3d ?? true;
|
|
10134
10098
|
},
|
|
10135
10099
|
get mobile() {
|
|
10136
|
-
return
|
|
10100
|
+
return browser.mobile ?? coarsePointer;
|
|
10137
10101
|
},
|
|
10138
10102
|
get mobileWebkit() {
|
|
10139
|
-
return
|
|
10103
|
+
return browser.mobileWebkit ?? false;
|
|
10140
10104
|
},
|
|
10141
10105
|
get mobileWebkit3d() {
|
|
10142
|
-
return
|
|
10106
|
+
return browser.mobileWebkit3d ?? false;
|
|
10143
10107
|
},
|
|
10144
10108
|
get msPointer() {
|
|
10145
|
-
return
|
|
10109
|
+
return browser.msPointer ?? false;
|
|
10146
10110
|
},
|
|
10147
10111
|
get pointer() {
|
|
10148
|
-
return
|
|
10112
|
+
return browser.pointer ?? typeof PointerEvent !== "undefined";
|
|
10149
10113
|
},
|
|
10150
10114
|
get touch() {
|
|
10151
|
-
return
|
|
10115
|
+
return browser.touch ?? coarsePointer;
|
|
10152
10116
|
},
|
|
10153
10117
|
get touchNative() {
|
|
10154
|
-
return
|
|
10118
|
+
return browser.touchNative ?? coarsePointer;
|
|
10155
10119
|
},
|
|
10156
10120
|
get mobileOpera() {
|
|
10157
|
-
return
|
|
10121
|
+
return browser.mobileOpera ?? false;
|
|
10158
10122
|
},
|
|
10159
10123
|
get mobileGecko() {
|
|
10160
|
-
return
|
|
10124
|
+
return browser.mobileGecko ?? false;
|
|
10161
10125
|
},
|
|
10162
10126
|
get retina() {
|
|
10163
|
-
return
|
|
10127
|
+
return browser.retina ?? (typeof devicePixelRatio !== "undefined" && devicePixelRatio > 1);
|
|
10164
10128
|
},
|
|
10165
10129
|
get passiveEvents() {
|
|
10166
|
-
return
|
|
10130
|
+
return browser.passiveEvents ?? true;
|
|
10167
10131
|
},
|
|
10168
10132
|
get canvas() {
|
|
10169
|
-
return
|
|
10133
|
+
return browser.canvas ?? true;
|
|
10170
10134
|
},
|
|
10171
10135
|
get svg() {
|
|
10172
|
-
return
|
|
10136
|
+
return browser.svg ?? true;
|
|
10173
10137
|
},
|
|
10174
10138
|
get vml() {
|
|
10175
|
-
return
|
|
10139
|
+
return browser.vml ?? false;
|
|
10176
10140
|
},
|
|
10177
10141
|
get inlineSvg() {
|
|
10178
|
-
return
|
|
10142
|
+
return browser.inlineSvg ?? true;
|
|
10179
10143
|
}
|
|
10180
10144
|
};
|
|
10181
10145
|
}
|
|
@@ -10313,7 +10277,8 @@ function createButtons(container, subContainer, config, onActivateToggle, onDraw
|
|
|
10313
10277
|
activate.dataset.collapsedIcon = icons$1.collapse;
|
|
10314
10278
|
L.DomEvent.on(activate, "mousedown", L.DomEvent.stopPropagation);
|
|
10315
10279
|
L.DomEvent.on(activate, "touchstart", L.DomEvent.stopPropagation);
|
|
10316
|
-
L.DomEvent.on(activate, "click", L.DomEvent.stop)
|
|
10280
|
+
L.DomEvent.on(activate, "click", L.DomEvent.stop);
|
|
10281
|
+
L.DomEvent.on(activate, "click", onActivateToggle);
|
|
10317
10282
|
if (config.tools.draw) {
|
|
10318
10283
|
const draw = leafletAdapter.domUtil.create("a", "icon-draw", subContainer);
|
|
10319
10284
|
draw.href = "#";
|
|
@@ -11185,7 +11150,7 @@ class PolygonDrawManager {
|
|
|
11185
11150
|
pointMarker.addTo(this.map);
|
|
11186
11151
|
this.applyP2PMarkerMode(pointMarker);
|
|
11187
11152
|
pointMarker.on("mousedown", (e) => {
|
|
11188
|
-
|
|
11153
|
+
leafletAdapter.domEvent.stopPropagation(e);
|
|
11189
11154
|
});
|
|
11190
11155
|
pointMarker.on("drag", () => {
|
|
11191
11156
|
this.updateP2PTracer();
|
|
@@ -11193,7 +11158,7 @@ class PolygonDrawManager {
|
|
|
11193
11158
|
pointMarker.on("click", (e) => {
|
|
11194
11159
|
if (this.shouldAllowP2PMarkerDeletion()) {
|
|
11195
11160
|
this.deleteP2PMarker(pointMarker);
|
|
11196
|
-
|
|
11161
|
+
leafletAdapter.domEvent.stopPropagation(e);
|
|
11197
11162
|
}
|
|
11198
11163
|
});
|
|
11199
11164
|
pointMarker.on("mouseover", () => this.onMarkerHoverForEdgeDeletion(pointMarker, true));
|
|
@@ -11223,11 +11188,11 @@ class PolygonDrawManager {
|
|
|
11223
11188
|
pointMarker.on("click", (e) => {
|
|
11224
11189
|
if (this.shouldAllowP2PMarkerDeletion()) {
|
|
11225
11190
|
this.deleteP2PMarker(pointMarker);
|
|
11226
|
-
|
|
11191
|
+
leafletAdapter.domEvent.stopPropagation(e);
|
|
11227
11192
|
return;
|
|
11228
11193
|
}
|
|
11229
11194
|
if (this.p2pMarkers.length >= 3) {
|
|
11230
|
-
|
|
11195
|
+
leafletAdapter.domEvent.stopPropagation(e);
|
|
11231
11196
|
this.completePointToPointPolygon();
|
|
11232
11197
|
}
|
|
11233
11198
|
});
|
|
@@ -11453,11 +11418,11 @@ class PolygonDrawManager {
|
|
|
11453
11418
|
firstMarker.on("click", (e) => {
|
|
11454
11419
|
if (this.shouldAllowP2PMarkerDeletion()) {
|
|
11455
11420
|
this.deleteP2PMarker(firstMarker);
|
|
11456
|
-
|
|
11421
|
+
leafletAdapter.domEvent.stopPropagation(e);
|
|
11457
11422
|
return;
|
|
11458
11423
|
}
|
|
11459
11424
|
if (this.p2pMarkers.length >= 3) {
|
|
11460
|
-
|
|
11425
|
+
leafletAdapter.domEvent.stopPropagation(e);
|
|
11461
11426
|
this.completePointToPointPolygon();
|
|
11462
11427
|
}
|
|
11463
11428
|
});
|
|
@@ -13443,6 +13408,7 @@ class PolygonInteractionManager {
|
|
|
13443
13408
|
__publicField(this, "dragUsesPointerEvents", false);
|
|
13444
13409
|
__publicField(this, "polygonTouchStartListeners", /* @__PURE__ */ new WeakMap());
|
|
13445
13410
|
__publicField(this, "polygonNativeStartListeners", /* @__PURE__ */ new WeakMap());
|
|
13411
|
+
__publicField(this, "polygonTouchActionValues", /* @__PURE__ */ new WeakMap());
|
|
13446
13412
|
__publicField(this, "_openMenuPopup", null);
|
|
13447
13413
|
__publicField(this, "transformModeActive", false);
|
|
13448
13414
|
__publicField(this, "transformControllers", /* @__PURE__ */ new WeakMap());
|
|
@@ -13611,6 +13577,7 @@ class PolygonInteractionManager {
|
|
|
13611
13577
|
* the polygon is restored unchanged.
|
|
13612
13578
|
*/
|
|
13613
13579
|
handleDonutCommit(controller, featureGroup, polygonLayer, optimizationLevel, originalOptimizationLevel) {
|
|
13580
|
+
var _a2;
|
|
13614
13581
|
const originalOuter = controller.getOriginalOuterLatLngs();
|
|
13615
13582
|
const donutValidation = controller.getDonutValidation();
|
|
13616
13583
|
const restore = () => {
|
|
@@ -13625,6 +13592,8 @@ class PolygonInteractionManager {
|
|
|
13625
13592
|
if (this.saveHistoryState) {
|
|
13626
13593
|
this.saveHistoryState("donut");
|
|
13627
13594
|
}
|
|
13595
|
+
const featureMetadataState = this.getFeatureMetadataState(featureGroup);
|
|
13596
|
+
const targetLayerId = (_a2 = this.layerManager) == null ? void 0 : _a2.getLayerForFeatureGroup(featureGroup);
|
|
13628
13597
|
this.cleanupFeatureGroup(featureGroup);
|
|
13629
13598
|
this.removeFeatureGroup(featureGroup);
|
|
13630
13599
|
this.emitPolygonUpdated({
|
|
@@ -13632,7 +13601,14 @@ class PolygonInteractionManager {
|
|
|
13632
13601
|
polygon: donutValidation.polygon,
|
|
13633
13602
|
allowMerge: donutValidation.allowMerge,
|
|
13634
13603
|
optimizationLevel,
|
|
13635
|
-
originalOptimizationLevel
|
|
13604
|
+
originalOptimizationLevel,
|
|
13605
|
+
featureId: featureMetadataState.featureId,
|
|
13606
|
+
featureMetadata: featureMetadataState.metadata,
|
|
13607
|
+
sourceFeatureIds: featureMetadataState.sourceFeatureIds,
|
|
13608
|
+
featureInteractionOverride: featureMetadataState.interactionOverride,
|
|
13609
|
+
featureStyleOverrides: featureMetadataState.styleOverrides,
|
|
13610
|
+
targetLayerId,
|
|
13611
|
+
featureCreatedAt: featureMetadataState.createdAt
|
|
13636
13612
|
});
|
|
13637
13613
|
}
|
|
13638
13614
|
dispose() {
|
|
@@ -13716,7 +13692,7 @@ class PolygonInteractionManager {
|
|
|
13716
13692
|
var _a2, _b2;
|
|
13717
13693
|
if (this.isDraggingMarker) {
|
|
13718
13694
|
(_b2 = (_a2 = e.originalEvent) == null ? void 0 : _a2.stopPropagation) == null ? void 0 : _b2.call(_a2);
|
|
13719
|
-
|
|
13695
|
+
leafletAdapter.domEvent.stopPropagation(e);
|
|
13720
13696
|
}
|
|
13721
13697
|
});
|
|
13722
13698
|
marker.on("dragstart", () => {
|
|
@@ -13744,7 +13720,7 @@ class PolygonInteractionManager {
|
|
|
13744
13720
|
this.markerDragEnd(fg);
|
|
13745
13721
|
}
|
|
13746
13722
|
this._activeMarker = null;
|
|
13747
|
-
|
|
13723
|
+
leafletAdapter.domEvent.stopPropagation(e);
|
|
13748
13724
|
setTimeout(() => {
|
|
13749
13725
|
this.isDraggingMarker = false;
|
|
13750
13726
|
}, 10);
|
|
@@ -13882,7 +13858,7 @@ class PolygonInteractionManager {
|
|
|
13882
13858
|
}
|
|
13883
13859
|
marker.on("mousedown", (e) => {
|
|
13884
13860
|
if (!this.modeManager.isInOffMode()) {
|
|
13885
|
-
|
|
13861
|
+
leafletAdapter.domEvent.stopPropagation(e);
|
|
13886
13862
|
this.map.fire("mousedown", e);
|
|
13887
13863
|
}
|
|
13888
13864
|
this._activeMarker = marker;
|
|
@@ -13986,7 +13962,7 @@ class PolygonInteractionManager {
|
|
|
13986
13962
|
var _a3, _b3;
|
|
13987
13963
|
if (this.isDraggingMarker) {
|
|
13988
13964
|
(_b3 = (_a3 = e.originalEvent) == null ? void 0 : _a3.stopPropagation) == null ? void 0 : _b3.call(_a3);
|
|
13989
|
-
|
|
13965
|
+
leafletAdapter.domEvent.stopPropagation(e);
|
|
13990
13966
|
}
|
|
13991
13967
|
});
|
|
13992
13968
|
marker.on("dragstart", () => {
|
|
@@ -14014,7 +13990,7 @@ class PolygonInteractionManager {
|
|
|
14014
13990
|
this.markerDragEnd(fg);
|
|
14015
13991
|
}
|
|
14016
13992
|
this._activeMarker = null;
|
|
14017
|
-
|
|
13993
|
+
leafletAdapter.domEvent.stopPropagation(e);
|
|
14018
13994
|
setTimeout(() => {
|
|
14019
13995
|
this.isDraggingMarker = false;
|
|
14020
13996
|
}, 10);
|
|
@@ -14127,7 +14103,7 @@ class PolygonInteractionManager {
|
|
|
14127
14103
|
}
|
|
14128
14104
|
marker.on("mousedown", (e) => {
|
|
14129
14105
|
if (!this.modeManager.isInOffMode()) {
|
|
14130
|
-
|
|
14106
|
+
leafletAdapter.domEvent.stopPropagation(e);
|
|
14131
14107
|
this.map.fire("mousedown", e);
|
|
14132
14108
|
}
|
|
14133
14109
|
this._activeMarker = marker;
|
|
@@ -14329,6 +14305,9 @@ class PolygonInteractionManager {
|
|
|
14329
14305
|
}
|
|
14330
14306
|
const existingDragData = polygon2._polydrawDragData;
|
|
14331
14307
|
if (this.currentDragPolygon === polygon2 && (existingDragData == null ? void 0 : existingDragData.isDragging)) {
|
|
14308
|
+
if (options.attachTouchListeners) {
|
|
14309
|
+
this.attachDragTouchListeners();
|
|
14310
|
+
}
|
|
14332
14311
|
return true;
|
|
14333
14312
|
}
|
|
14334
14313
|
const isCloneMode = this.modeManager.getCurrentMode() === DrawMode.Clone;
|
|
@@ -14384,22 +14363,27 @@ class PolygonInteractionManager {
|
|
|
14384
14363
|
});
|
|
14385
14364
|
};
|
|
14386
14365
|
const listeners = {
|
|
14387
|
-
|
|
14388
|
-
|
|
14366
|
+
pointerdown: (event) => {
|
|
14367
|
+
if (LeafletVersionDetector.isV1() && event.pointerType === "mouse") return;
|
|
14368
|
+
startFromNativeEvent(event);
|
|
14369
|
+
},
|
|
14389
14370
|
touchstart: (event) => startFromNativeEvent(event)
|
|
14390
14371
|
};
|
|
14391
14372
|
this.polygonNativeStartListeners.set(polygon2, listeners);
|
|
14392
14373
|
const attach = () => {
|
|
14393
14374
|
const el = polygon2._path;
|
|
14394
14375
|
if (!el) return;
|
|
14395
|
-
|
|
14376
|
+
if (!this.polygonTouchActionValues.has(polygon2)) {
|
|
14377
|
+
this.polygonTouchActionValues.set(polygon2, el.style.touchAction);
|
|
14378
|
+
}
|
|
14379
|
+
el.style.touchAction = "none";
|
|
14396
14380
|
el.addEventListener("pointerdown", listeners.pointerdown, { capture: true });
|
|
14397
14381
|
el.addEventListener("touchstart", listeners.touchstart, { capture: true, passive: false });
|
|
14398
14382
|
};
|
|
14399
14383
|
if (polygon2._path) {
|
|
14400
14384
|
attach();
|
|
14401
14385
|
} else {
|
|
14402
|
-
polygon2.once("add", attach);
|
|
14386
|
+
polygon2.once("add", () => requestAnimationFrame(attach));
|
|
14403
14387
|
}
|
|
14404
14388
|
}
|
|
14405
14389
|
/**
|
|
@@ -14414,9 +14398,10 @@ class PolygonInteractionManager {
|
|
|
14414
14398
|
startLatLngs: null,
|
|
14415
14399
|
originalOpacity: polygon2.options.fillOpacity
|
|
14416
14400
|
};
|
|
14417
|
-
polygon2.on("mousedown", (
|
|
14401
|
+
polygon2.on("mousedown", (event) => {
|
|
14402
|
+
const e = event;
|
|
14418
14403
|
if (!this.isPolygonDragModeActive()) {
|
|
14419
|
-
|
|
14404
|
+
leafletAdapter.domEvent.stopPropagation(e);
|
|
14420
14405
|
this.map.fire("mousedown", e);
|
|
14421
14406
|
return;
|
|
14422
14407
|
}
|
|
@@ -14456,7 +14441,7 @@ class PolygonInteractionManager {
|
|
|
14456
14441
|
if (polygon2._path) {
|
|
14457
14442
|
attachTouch();
|
|
14458
14443
|
} else {
|
|
14459
|
-
polygon2.once("add", attachTouch);
|
|
14444
|
+
polygon2.once("add", () => requestAnimationFrame(attachTouch));
|
|
14460
14445
|
}
|
|
14461
14446
|
}
|
|
14462
14447
|
this.attachPolygonNativeStartListeners(polygon2);
|
|
@@ -14683,7 +14668,7 @@ class PolygonInteractionManager {
|
|
|
14683
14668
|
} catch {
|
|
14684
14669
|
}
|
|
14685
14670
|
}
|
|
14686
|
-
|
|
14671
|
+
leafletAdapter.domEvent.stopPropagation(e);
|
|
14687
14672
|
}
|
|
14688
14673
|
highlightEdgeOnHover(edgePolyline, isHovering) {
|
|
14689
14674
|
if (isHovering) {
|
|
@@ -15172,10 +15157,11 @@ class PolygonInteractionManager {
|
|
|
15172
15157
|
if (!listeners) return;
|
|
15173
15158
|
const el = polygon2._path;
|
|
15174
15159
|
if (el) {
|
|
15175
|
-
el.removeEventListener("mousedown", listeners.mousedown, { capture: true });
|
|
15176
15160
|
el.removeEventListener("pointerdown", listeners.pointerdown, { capture: true });
|
|
15177
15161
|
el.removeEventListener("touchstart", listeners.touchstart, { capture: true });
|
|
15162
|
+
el.style.touchAction = this.polygonTouchActionValues.get(polygon2) ?? "";
|
|
15178
15163
|
}
|
|
15164
|
+
this.polygonTouchActionValues.delete(polygon2);
|
|
15179
15165
|
this.polygonNativeStartListeners.delete(polygon2);
|
|
15180
15166
|
}
|
|
15181
15167
|
attachDragCancelHandlers() {
|
|
@@ -16659,6 +16645,7 @@ class PolygonInteractionManager {
|
|
|
16659
16645
|
}
|
|
16660
16646
|
}
|
|
16661
16647
|
handleTransformControllerResult(controller, featureGroup, mode, confirmed) {
|
|
16648
|
+
var _a2;
|
|
16662
16649
|
if (this.transformControllers.get(featureGroup) === controller) {
|
|
16663
16650
|
this.transformControllers.delete(featureGroup);
|
|
16664
16651
|
}
|
|
@@ -16687,6 +16674,7 @@ class PolygonInteractionManager {
|
|
|
16687
16674
|
}
|
|
16688
16675
|
const newGeoJSON = polygonLayer.toGeoJSON();
|
|
16689
16676
|
const featureMetadataState = this.getFeatureMetadataState(featureGroup);
|
|
16677
|
+
const targetLayerId = (_a2 = this.layerManager) == null ? void 0 : _a2.getLayerForFeatureGroup(featureGroup);
|
|
16690
16678
|
this.cleanupFeatureGroup(featureGroup);
|
|
16691
16679
|
this.removeFeatureGroup(featureGroup);
|
|
16692
16680
|
this.emitPolygonUpdated({
|
|
@@ -16700,6 +16688,7 @@ class PolygonInteractionManager {
|
|
|
16700
16688
|
sourceFeatureIds: featureMetadataState.sourceFeatureIds,
|
|
16701
16689
|
featureInteractionOverride: featureMetadataState.interactionOverride,
|
|
16702
16690
|
featureStyleOverrides: featureMetadataState.styleOverrides,
|
|
16691
|
+
targetLayerId,
|
|
16703
16692
|
featureCreatedAt: featureMetadataState.createdAt
|
|
16704
16693
|
});
|
|
16705
16694
|
}
|
|
@@ -17147,7 +17136,7 @@ class PolygonMutationManager {
|
|
|
17147
17136
|
* Handle menu actions from interaction manager
|
|
17148
17137
|
*/
|
|
17149
17138
|
async handleMenuAction(data) {
|
|
17150
|
-
var _a2, _b2, _c, _d;
|
|
17139
|
+
var _a2, _b2, _c, _d, _e;
|
|
17151
17140
|
if (!(data == null ? void 0 : data.featureGroup)) {
|
|
17152
17141
|
return;
|
|
17153
17142
|
}
|
|
@@ -17166,6 +17155,7 @@ class PolygonMutationManager {
|
|
|
17166
17155
|
}
|
|
17167
17156
|
const { level: optimizationLevel, original: originalOptimizationLevel } = this.getOptimizationMetadataFromFeatureGroup(data.featureGroup);
|
|
17168
17157
|
const sourceMetadata = this.getFeatureMetadataStateFromFeatureGroup(data.featureGroup);
|
|
17158
|
+
const sourceLayerId = (_a2 = this.layerManager) == null ? void 0 : _a2.getLayerForFeatureGroup(data.featureGroup);
|
|
17169
17159
|
let result;
|
|
17170
17160
|
let shouldSaveHistory = true;
|
|
17171
17161
|
switch (data.action) {
|
|
@@ -17203,8 +17193,8 @@ class PolygonMutationManager {
|
|
|
17203
17193
|
this.saveHistoryState(data.action);
|
|
17204
17194
|
}
|
|
17205
17195
|
this.removeFeatureGroupInternal(data.featureGroup);
|
|
17206
|
-
const bezierLevel = data.action === "bezier" ? ((
|
|
17207
|
-
const bezierOriginal = data.action === "bezier" ? ((
|
|
17196
|
+
const bezierLevel = data.action === "bezier" ? ((_b2 = this.config.polygonTools.bezier) == null ? void 0 : _b2.visualOptimizationLevel) ?? 10 : optimizationLevel;
|
|
17197
|
+
const bezierOriginal = data.action === "bezier" ? ((_c = this.config.polygonTools.bezier) == null ? void 0 : _c.visualOptimizationLevel) ?? 10 : originalOptimizationLevel;
|
|
17208
17198
|
const noMerge = result.allowMerge === false;
|
|
17209
17199
|
const shouldSimplify = result.simplify === true;
|
|
17210
17200
|
const resultMetadata = result.metadata ?? sourceMetadata.metadata;
|
|
@@ -17218,11 +17208,12 @@ class PolygonMutationManager {
|
|
|
17218
17208
|
sourceFeatureIds: sourceMetadata.sourceFeatureIds,
|
|
17219
17209
|
featureInteractionOverride: sourceMetadata.interactionOverride,
|
|
17220
17210
|
featureStyleOverrides: sourceMetadata.styleOverrides,
|
|
17211
|
+
targetLayerId: sourceLayerId,
|
|
17221
17212
|
featureCreatedAt: sourceMetadata.createdAt
|
|
17222
17213
|
});
|
|
17223
|
-
if (data.action === "bezier" && ((
|
|
17214
|
+
if (data.action === "bezier" && ((_d = this.config.polygonTools.bezier) == null ? void 0 : _d.ghostMarkers)) {
|
|
17224
17215
|
const ghostOpacity = 1e-3;
|
|
17225
|
-
(
|
|
17216
|
+
(_e = addResult.featureGroups) == null ? void 0 : _e.forEach((featureGroup) => {
|
|
17226
17217
|
featureGroup.eachLayer((layer) => {
|
|
17227
17218
|
if (layer instanceof L.Polygon) {
|
|
17228
17219
|
const polygon2 = layer;
|
|
@@ -19456,12 +19447,14 @@ function createLayerPanel(layerManager, eventManager, initialState = "expanded",
|
|
|
19456
19447
|
layerEditorBackdrop = null;
|
|
19457
19448
|
};
|
|
19458
19449
|
const openLayerEditor = (layer) => {
|
|
19459
|
-
var _a2;
|
|
19450
|
+
var _a2, _b2;
|
|
19460
19451
|
closeLayerEditor();
|
|
19461
19452
|
const initialColor = normalizeHexColor(layer.color, "#50622b");
|
|
19462
19453
|
let selectedColor = initialColor;
|
|
19463
19454
|
let mergeMode = false;
|
|
19464
19455
|
let selectedTargetLayerId = null;
|
|
19456
|
+
let createNewMergeTarget = false;
|
|
19457
|
+
const canCreateMergeTarget = layer.role === "reference";
|
|
19465
19458
|
const targetLayers = layerManager.getAllLayers().filter((candidate) => candidate.role === "draw" && candidate.id !== layer.id);
|
|
19466
19459
|
const backdrop = document.createElement("div");
|
|
19467
19460
|
backdrop.className = "polydraw-layer-dialog-backdrop";
|
|
@@ -19531,7 +19524,7 @@ function createLayerPanel(layerManager, eventManager, initialState = "expanded",
|
|
|
19531
19524
|
commands.className = "polydraw-layer-dialog-commands";
|
|
19532
19525
|
const sourceFeatureCount = layerManager.getFeatureGroupsForLayer(layer.id).length;
|
|
19533
19526
|
const canMergeSource = layer.role === "draw" || layer.role === "reference" && allowReferenceMergeSources;
|
|
19534
|
-
if (canMergeSource && sourceFeatureCount > 0 && targetLayers.length > 0) {
|
|
19527
|
+
if (canMergeSource && sourceFeatureCount > 0 && (targetLayers.length > 0 || canCreateMergeTarget)) {
|
|
19535
19528
|
const mergeButton = document.createElement("button");
|
|
19536
19529
|
mergeButton.type = "button";
|
|
19537
19530
|
mergeButton.className = "polydraw-layer-dialog-merge";
|
|
@@ -19577,6 +19570,33 @@ function createLayerPanel(layerManager, eventManager, initialState = "expanded",
|
|
|
19577
19570
|
mergeOptions.appendChild(option);
|
|
19578
19571
|
return option;
|
|
19579
19572
|
});
|
|
19573
|
+
if (canCreateMergeTarget) {
|
|
19574
|
+
const newLayerOption = document.createElement("button");
|
|
19575
|
+
newLayerOption.type = "button";
|
|
19576
|
+
newLayerOption.className = "polygon-layer-option polygon-layer-option-new polydraw-layer-merge-option polydraw-layer-merge-option-new";
|
|
19577
|
+
newLayerOption.setAttribute("role", "radio");
|
|
19578
|
+
newLayerOption.setAttribute("aria-checked", "false");
|
|
19579
|
+
newLayerOption.dataset.createNewLayer = "true";
|
|
19580
|
+
const label = document.createElement("span");
|
|
19581
|
+
label.className = "polygon-layer-option-label";
|
|
19582
|
+
label.textContent = "+ New editable layer";
|
|
19583
|
+
newLayerOption.appendChild(label);
|
|
19584
|
+
mergeOptions.appendChild(newLayerOption);
|
|
19585
|
+
mergeOptionButtons.push(newLayerOption);
|
|
19586
|
+
}
|
|
19587
|
+
const newLayerNameField = document.createElement("label");
|
|
19588
|
+
newLayerNameField.className = "polygon-layer-new-name polydraw-layer-merge-new-name";
|
|
19589
|
+
newLayerNameField.hidden = true;
|
|
19590
|
+
const newLayerNameLabel = document.createElement("span");
|
|
19591
|
+
newLayerNameLabel.textContent = "Layer name";
|
|
19592
|
+
const newLayerNameInput = document.createElement("input");
|
|
19593
|
+
newLayerNameInput.type = "text";
|
|
19594
|
+
newLayerNameInput.className = "polygon-layer-new-name-input polydraw-layer-new-name-input";
|
|
19595
|
+
newLayerNameInput.value = ((_a2 = layer.label) == null ? void 0 : _a2.trim()) || layer.id;
|
|
19596
|
+
newLayerNameInput.placeholder = "Optional";
|
|
19597
|
+
newLayerNameInput.maxLength = 80;
|
|
19598
|
+
newLayerNameInput.autocomplete = "off";
|
|
19599
|
+
newLayerNameField.append(newLayerNameLabel, newLayerNameInput);
|
|
19580
19600
|
const targetStyleChoice = document.createElement("label");
|
|
19581
19601
|
targetStyleChoice.className = "polydraw-layer-merge-style-choice";
|
|
19582
19602
|
const targetStyleCheckbox = document.createElement("input");
|
|
@@ -19589,7 +19609,11 @@ function createLayerPanel(layerManager, eventManager, initialState = "expanded",
|
|
|
19589
19609
|
targetStyleDescription.textContent = "Otherwise individual colors and opacity are preserved.";
|
|
19590
19610
|
targetStyleText.append(targetStyleLabel, targetStyleDescription);
|
|
19591
19611
|
targetStyleChoice.append(targetStyleCheckbox, targetStyleText);
|
|
19592
|
-
mergePanel.
|
|
19612
|
+
mergePanel.appendChild(mergeOptions);
|
|
19613
|
+
if (canCreateMergeTarget) {
|
|
19614
|
+
mergePanel.appendChild(newLayerNameField);
|
|
19615
|
+
}
|
|
19616
|
+
mergePanel.appendChild(targetStyleChoice);
|
|
19593
19617
|
const actions = document.createElement("div");
|
|
19594
19618
|
actions.className = "polydraw-layer-dialog-actions";
|
|
19595
19619
|
const cancelButton = document.createElement("button");
|
|
@@ -19640,16 +19664,22 @@ function createLayerPanel(layerManager, eventManager, initialState = "expanded",
|
|
|
19640
19664
|
cancelButton.addEventListener("click", closeWithoutApply);
|
|
19641
19665
|
mergeCancelButton.addEventListener("click", closeWithoutApply);
|
|
19642
19666
|
backButton.addEventListener("click", showSettings);
|
|
19643
|
-
(
|
|
19667
|
+
(_b2 = commands.querySelector(".polydraw-layer-dialog-merge")) == null ? void 0 : _b2.addEventListener("click", showMergeTargets);
|
|
19644
19668
|
mergeOptionButtons.forEach((option) => {
|
|
19645
19669
|
option.addEventListener("click", () => {
|
|
19646
|
-
|
|
19670
|
+
createNewMergeTarget = option.dataset.createNewLayer === "true";
|
|
19671
|
+
selectedTargetLayerId = createNewMergeTarget ? null : option.dataset.layerId || null;
|
|
19647
19672
|
mergeOptionButtons.forEach((candidate) => {
|
|
19648
19673
|
const selected = candidate === option;
|
|
19649
19674
|
candidate.classList.toggle("selected", selected);
|
|
19650
19675
|
candidate.setAttribute("aria-checked", String(selected));
|
|
19651
19676
|
});
|
|
19652
|
-
|
|
19677
|
+
newLayerNameField.hidden = !createNewMergeTarget;
|
|
19678
|
+
targetStyleChoice.hidden = createNewMergeTarget;
|
|
19679
|
+
mergeApplyButton.disabled = !createNewMergeTarget && selectedTargetLayerId === null;
|
|
19680
|
+
if (createNewMergeTarget) {
|
|
19681
|
+
newLayerNameInput.focus();
|
|
19682
|
+
}
|
|
19653
19683
|
});
|
|
19654
19684
|
});
|
|
19655
19685
|
if (mergeOptionButtons.length === 1) {
|
|
@@ -19660,11 +19690,13 @@ function createLayerPanel(layerManager, eventManager, initialState = "expanded",
|
|
|
19660
19690
|
mergeApplyButton.disabled = selectedTargetLayerId === null;
|
|
19661
19691
|
}
|
|
19662
19692
|
mergeApplyButton.addEventListener("click", () => {
|
|
19663
|
-
if (!selectedTargetLayerId) return;
|
|
19693
|
+
if (!createNewMergeTarget && !selectedTargetLayerId) return;
|
|
19664
19694
|
eventManager.emit("polydraw:layer:merge-requested", {
|
|
19665
19695
|
sourceLayerId: layer.id,
|
|
19666
|
-
targetLayerId: selectedTargetLayerId,
|
|
19667
|
-
|
|
19696
|
+
targetLayerId: selectedTargetLayerId ?? void 0,
|
|
19697
|
+
createNewLayer: createNewMergeTarget,
|
|
19698
|
+
newLayerLabel: createNewMergeTarget ? newLayerNameInput.value.trim() || void 0 : void 0,
|
|
19699
|
+
useTargetStyle: createNewMergeTarget ? false : targetStyleCheckbox.checked
|
|
19668
19700
|
});
|
|
19669
19701
|
closeLayerEditor();
|
|
19670
19702
|
});
|
|
@@ -19990,10 +20022,10 @@ function createLayerPanel(layerManager, eventManager, initialState = "expanded",
|
|
|
19990
20022
|
);
|
|
19991
20023
|
}
|
|
19992
20024
|
};
|
|
19993
|
-
|
|
19994
|
-
|
|
19995
|
-
position: "topright"
|
|
19996
|
-
}
|
|
20025
|
+
class LayerPanelControlClass extends L.Control {
|
|
20026
|
+
constructor() {
|
|
20027
|
+
super({ position: "topright" });
|
|
20028
|
+
}
|
|
19997
20029
|
onAdd(leafletMap) {
|
|
19998
20030
|
map = leafletMap;
|
|
19999
20031
|
container = L.DomUtil.create("div", "leaflet-bar polydraw-layer-panel");
|
|
@@ -20008,7 +20040,7 @@ function createLayerPanel(layerManager, eventManager, initialState = "expanded",
|
|
|
20008
20040
|
renderPanel();
|
|
20009
20041
|
map.on("resize", updateAvailableHeight);
|
|
20010
20042
|
return container;
|
|
20011
|
-
}
|
|
20043
|
+
}
|
|
20012
20044
|
onRemove() {
|
|
20013
20045
|
if (!container) {
|
|
20014
20046
|
return;
|
|
@@ -20026,12 +20058,11 @@ function createLayerPanel(layerManager, eventManager, initialState = "expanded",
|
|
|
20026
20058
|
draggedLayerId = null;
|
|
20027
20059
|
pendingRenderWhileDragging = false;
|
|
20028
20060
|
}
|
|
20029
|
-
|
|
20030
|
-
|
|
20031
|
-
|
|
20032
|
-
|
|
20033
|
-
|
|
20034
|
-
return panel;
|
|
20061
|
+
refresh(options) {
|
|
20062
|
+
renderPanel(options);
|
|
20063
|
+
}
|
|
20064
|
+
}
|
|
20065
|
+
return new LayerPanelControlClass();
|
|
20035
20066
|
}
|
|
20036
20067
|
function injectDynamicStyles(config) {
|
|
20037
20068
|
const style = document.createElement("style");
|
|
@@ -20141,19 +20172,17 @@ class CoordinateUtils {
|
|
|
20141
20172
|
*/
|
|
20142
20173
|
static convertToCoords(latlngs, turfHelper) {
|
|
20143
20174
|
const coords = [];
|
|
20175
|
+
const toRing = (ring) => L.GeoJSON.latLngsToCoords(ring);
|
|
20144
20176
|
if (latlngs.length > 1 && latlngs.length < 3) {
|
|
20145
20177
|
const coordinates = [];
|
|
20146
|
-
const within = turfHelper.isWithin(
|
|
20147
|
-
L.GeoJSON.latLngsToCoords(latlngs[latlngs.length - 1]),
|
|
20148
|
-
L.GeoJSON.latLngsToCoords(latlngs[0])
|
|
20149
|
-
);
|
|
20178
|
+
const within = turfHelper.isWithin(toRing(latlngs[latlngs.length - 1]), toRing(latlngs[0]));
|
|
20150
20179
|
if (within) {
|
|
20151
20180
|
latlngs.forEach((polygon2) => {
|
|
20152
|
-
coordinates.push(
|
|
20181
|
+
coordinates.push(toRing(polygon2));
|
|
20153
20182
|
});
|
|
20154
20183
|
} else {
|
|
20155
20184
|
latlngs.forEach((polygon2) => {
|
|
20156
|
-
coords.push([
|
|
20185
|
+
coords.push([toRing(polygon2)]);
|
|
20157
20186
|
});
|
|
20158
20187
|
}
|
|
20159
20188
|
if (coordinates.length >= 1) {
|
|
@@ -20162,23 +20191,20 @@ class CoordinateUtils {
|
|
|
20162
20191
|
} else if (latlngs.length > 2) {
|
|
20163
20192
|
const coordinates = [];
|
|
20164
20193
|
for (let index = 1; index < latlngs.length - 1; index++) {
|
|
20165
|
-
const within = turfHelper.isWithin(
|
|
20166
|
-
L.GeoJSON.latLngsToCoords(latlngs[index]),
|
|
20167
|
-
L.GeoJSON.latLngsToCoords(latlngs[0])
|
|
20168
|
-
);
|
|
20194
|
+
const within = turfHelper.isWithin(toRing(latlngs[index]), toRing(latlngs[0]));
|
|
20169
20195
|
if (within) {
|
|
20170
20196
|
latlngs.forEach((polygon2) => {
|
|
20171
|
-
coordinates.push(
|
|
20197
|
+
coordinates.push(toRing(polygon2));
|
|
20172
20198
|
});
|
|
20173
20199
|
coords.push(coordinates);
|
|
20174
20200
|
} else {
|
|
20175
20201
|
latlngs.forEach((polygon2) => {
|
|
20176
|
-
coords.push([
|
|
20202
|
+
coords.push([toRing(polygon2)]);
|
|
20177
20203
|
});
|
|
20178
20204
|
}
|
|
20179
20205
|
}
|
|
20180
20206
|
} else {
|
|
20181
|
-
coords.push([
|
|
20207
|
+
coords.push([toRing(latlngs[0])]);
|
|
20182
20208
|
}
|
|
20183
20209
|
return coords;
|
|
20184
20210
|
}
|
|
@@ -20691,6 +20717,18 @@ class Polydraw extends L.Control {
|
|
|
20691
20717
|
__publicField(this, "_boundPointerUp");
|
|
20692
20718
|
__publicField(this, "_boundPointerCancel");
|
|
20693
20719
|
__publicField(this, "_boundContextMenu");
|
|
20720
|
+
__publicField(this, "_mapMouseDown", (event) => {
|
|
20721
|
+
this.mouseDown(event);
|
|
20722
|
+
});
|
|
20723
|
+
__publicField(this, "_mapMouseMove", (event) => {
|
|
20724
|
+
this.mouseMove(event);
|
|
20725
|
+
});
|
|
20726
|
+
__publicField(this, "_mapMouseUp", (event) => {
|
|
20727
|
+
void this.mouseUpLeave(event);
|
|
20728
|
+
});
|
|
20729
|
+
__publicField(this, "_mapDoubleClick", (event) => {
|
|
20730
|
+
this.handleDoubleClick(event);
|
|
20731
|
+
});
|
|
20694
20732
|
__publicField(this, "_lastTapTime", 0);
|
|
20695
20733
|
__publicField(this, "_lastTapLatLng", null);
|
|
20696
20734
|
__publicField(this, "_tapTimeout", null);
|
|
@@ -20845,7 +20883,7 @@ class Polydraw extends L.Control {
|
|
|
20845
20883
|
*/
|
|
20846
20884
|
onAdd(_map) {
|
|
20847
20885
|
const extendedMap = _map;
|
|
20848
|
-
const browser =
|
|
20886
|
+
const browser = leafletAdapter.getBrowser();
|
|
20849
20887
|
extendedMap._onResize = () => {
|
|
20850
20888
|
};
|
|
20851
20889
|
if (browser.touch && browser.mobile) {
|
|
@@ -21398,6 +21436,7 @@ class Polydraw extends L.Control {
|
|
|
21398
21436
|
*/
|
|
21399
21437
|
createDrawLayer(input = {}) {
|
|
21400
21438
|
const id = (input.id || this.getNextDrawLayerName()).trim();
|
|
21439
|
+
const firstReferenceIndex = this.layerManager.getAllLayers().findIndex((candidate) => candidate.role === "reference");
|
|
21401
21440
|
const layer = this.createLayer({
|
|
21402
21441
|
...input,
|
|
21403
21442
|
id,
|
|
@@ -21408,6 +21447,9 @@ class Polydraw extends L.Control {
|
|
|
21408
21447
|
panel: input.panel ?? "visible",
|
|
21409
21448
|
visibility: input.visibility ?? true
|
|
21410
21449
|
});
|
|
21450
|
+
if (firstReferenceIndex >= 0) {
|
|
21451
|
+
this.layerManager.moveLayerToIndex(layer.id, firstReferenceIndex);
|
|
21452
|
+
}
|
|
21411
21453
|
this.layerManager.setActiveLayer(layer.id);
|
|
21412
21454
|
this.updateLayerPanel();
|
|
21413
21455
|
this.updateMarkerDraggableState();
|
|
@@ -21741,6 +21783,41 @@ class Polydraw extends L.Control {
|
|
|
21741
21783
|
"layerMove",
|
|
21742
21784
|
this.layerManager
|
|
21743
21785
|
);
|
|
21786
|
+
return this.mergeLayerIntoWithSnapshot(
|
|
21787
|
+
normalizedSourceId,
|
|
21788
|
+
normalizedTargetId,
|
|
21789
|
+
options,
|
|
21790
|
+
historySnapshot
|
|
21791
|
+
);
|
|
21792
|
+
}
|
|
21793
|
+
async mergeLayerIntoNewDrawLayer(sourceLayerId, label) {
|
|
21794
|
+
var _a2;
|
|
21795
|
+
const normalizedSourceId = (sourceLayerId || "").trim();
|
|
21796
|
+
const sourceLayer = this.layerManager.getLayer(normalizedSourceId);
|
|
21797
|
+
if (!sourceLayer || sourceLayer.role !== "reference" || ((_a2 = this.config.layerPanel.merge) == null ? void 0 : _a2.allowReferenceSources) !== true || this.layerManager.getFeatureGroupsForLayer(normalizedSourceId).length === 0) {
|
|
21798
|
+
return false;
|
|
21799
|
+
}
|
|
21800
|
+
const historySnapshot = this.historyManager.captureState(
|
|
21801
|
+
this.arrayOfFeatureGroups,
|
|
21802
|
+
"layerMove",
|
|
21803
|
+
this.layerManager
|
|
21804
|
+
);
|
|
21805
|
+
try {
|
|
21806
|
+
const targetLayer = this.createDrawLayer({ label: (label == null ? void 0 : label.trim()) || void 0 });
|
|
21807
|
+
return await this.mergeLayerIntoWithSnapshot(
|
|
21808
|
+
normalizedSourceId,
|
|
21809
|
+
targetLayer.id,
|
|
21810
|
+
{ useTargetStyle: false },
|
|
21811
|
+
historySnapshot
|
|
21812
|
+
);
|
|
21813
|
+
} catch (error) {
|
|
21814
|
+
await this.restoreFromSnapshot(historySnapshot);
|
|
21815
|
+
console.warn("Failed to create a draw layer for merge; restored the previous state.", error);
|
|
21816
|
+
return false;
|
|
21817
|
+
}
|
|
21818
|
+
}
|
|
21819
|
+
async mergeLayerIntoWithSnapshot(normalizedSourceId, normalizedTargetId, options, historySnapshot) {
|
|
21820
|
+
const sourceFeatureGroups = this.layerManager.getFeatureGroupsForLayer(normalizedSourceId);
|
|
21744
21821
|
const sourceWasActive = this.layerManager.getActiveLayerId() === normalizedSourceId;
|
|
21745
21822
|
try {
|
|
21746
21823
|
for (const featureGroup of sourceFeatureGroups) {
|
|
@@ -22258,6 +22335,11 @@ class Polydraw extends L.Control {
|
|
|
22258
22335
|
void this.moveFeatureGroupToDrawLayer(data.featureGroup, targetLayer.id);
|
|
22259
22336
|
});
|
|
22260
22337
|
this.addCoreEventListener("polydraw:layer:merge-requested", (data) => {
|
|
22338
|
+
if (data.createNewLayer) {
|
|
22339
|
+
void this.mergeLayerIntoNewDrawLayer(data.sourceLayerId, data.newLayerLabel);
|
|
22340
|
+
return;
|
|
22341
|
+
}
|
|
22342
|
+
if (!data.targetLayerId) return;
|
|
22261
22343
|
void this.mergeLayerInto(data.sourceLayerId, data.targetLayerId, {
|
|
22262
22344
|
useTargetStyle: data.useTargetStyle
|
|
22263
22345
|
});
|
|
@@ -22772,6 +22854,10 @@ class Polydraw extends L.Control {
|
|
|
22772
22854
|
var _a2;
|
|
22773
22855
|
(_a2 = this.tracer) == null ? void 0 : _a2.setLatLngs([]);
|
|
22774
22856
|
}
|
|
22857
|
+
toggleMapEvent(type, handler, enabled) {
|
|
22858
|
+
const evented = this.map;
|
|
22859
|
+
evented[enabled ? "on" : "off"](type, handler);
|
|
22860
|
+
}
|
|
22775
22861
|
/**
|
|
22776
22862
|
* Attaches or detaches the mouse move and mouse up event listeners for drawing.
|
|
22777
22863
|
* @param onoff - A boolean indicating whether to attach or detach the events.
|
|
@@ -22782,10 +22868,9 @@ class Polydraw extends L.Control {
|
|
|
22782
22868
|
}
|
|
22783
22869
|
this.drawEventsAttached = onoff;
|
|
22784
22870
|
const usePointerEvents = this.pointerEventsHandled;
|
|
22785
|
-
const onoroff = onoff ? "on" : "off";
|
|
22786
22871
|
if (!usePointerEvents) {
|
|
22787
|
-
this.
|
|
22788
|
-
this.
|
|
22872
|
+
this.toggleMapEvent("mousemove", this._mapMouseMove, onoff);
|
|
22873
|
+
this.toggleMapEvent("mouseup", this._mapMouseUp, onoff);
|
|
22789
22874
|
}
|
|
22790
22875
|
if (onoff) {
|
|
22791
22876
|
if (!this._boundMouseMove) {
|
|
@@ -22861,11 +22946,10 @@ class Polydraw extends L.Control {
|
|
|
22861
22946
|
}
|
|
22862
22947
|
this.mapEventsAttached = onoff;
|
|
22863
22948
|
const usePointerEvents = this.pointerEventsHandled;
|
|
22864
|
-
const onoroff = onoff ? "on" : "off";
|
|
22865
22949
|
if (!usePointerEvents) {
|
|
22866
|
-
this.
|
|
22950
|
+
this.toggleMapEvent("mousedown", this._mapMouseDown, onoff);
|
|
22867
22951
|
}
|
|
22868
|
-
this.
|
|
22952
|
+
this.toggleMapEvent("dblclick", this._mapDoubleClick, onoff);
|
|
22869
22953
|
if (onoff) {
|
|
22870
22954
|
if (!this._boundContextMenu) {
|
|
22871
22955
|
this._boundContextMenu = (e) => e.preventDefault();
|