zenit-sdk 0.0.7 → 0.0.8
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/dist/{chunk-ITF7QCUZ.mjs → chunk-52CLFD4L.mjs} +230 -87
- package/dist/chunk-52CLFD4L.mjs.map +1 -0
- package/dist/index.js +229 -86
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/react/index.js +229 -86
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-ITF7QCUZ.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1470,6 +1470,7 @@ function getEffectiveLayerOpacity(baseOpacity, zoom, layerType, geometryType, op
|
|
|
1470
1470
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1471
1471
|
var DEFAULT_CENTER = [0, 0];
|
|
1472
1472
|
var DEFAULT_ZOOM = 3;
|
|
1473
|
+
var LABELS_PANE_NAME = "zenit-labels-pane";
|
|
1473
1474
|
function computeBBoxFromGeojson(geojson) {
|
|
1474
1475
|
if (!geojson) return null;
|
|
1475
1476
|
if (!Array.isArray(geojson.features) || geojson.features.length === 0) return null;
|
|
@@ -1510,6 +1511,23 @@ function mergeBBoxes(bboxes) {
|
|
|
1510
1511
|
{ ...first }
|
|
1511
1512
|
);
|
|
1512
1513
|
}
|
|
1514
|
+
function isRecord(value) {
|
|
1515
|
+
return typeof value === "object" && value !== null;
|
|
1516
|
+
}
|
|
1517
|
+
function isGeoJsonFeatureCollection(value) {
|
|
1518
|
+
if (!isRecord(value)) return false;
|
|
1519
|
+
const features = value.features;
|
|
1520
|
+
if (!Array.isArray(features)) return false;
|
|
1521
|
+
const type = value.type;
|
|
1522
|
+
return type === void 0 || type === "FeatureCollection";
|
|
1523
|
+
}
|
|
1524
|
+
function extractGeoJsonFeatureCollection(value) {
|
|
1525
|
+
if (isRecord(value) && "data" in value) {
|
|
1526
|
+
const data = value.data;
|
|
1527
|
+
return isGeoJsonFeatureCollection(data) ? data : null;
|
|
1528
|
+
}
|
|
1529
|
+
return isGeoJsonFeatureCollection(value) ? value : null;
|
|
1530
|
+
}
|
|
1513
1531
|
function getFeatureLayerId(feature) {
|
|
1514
1532
|
const layerId = feature?.properties?.__zenit_layerId ?? feature?.properties?.layerId ?? feature?.properties?.layer_id;
|
|
1515
1533
|
if (layerId === void 0 || layerId === null) return null;
|
|
@@ -1520,6 +1538,7 @@ function escapeHtml(value) {
|
|
|
1520
1538
|
}
|
|
1521
1539
|
var DESCRIPTION_KEYS = /* @__PURE__ */ new Set(["descripcion", "description"]);
|
|
1522
1540
|
var POPUP_EXCLUDED_KEYS = /* @__PURE__ */ new Set(["geom", "geometry"]);
|
|
1541
|
+
var POPUP_HEADER_KEYS = ["nombre", "name", "title", "titulo"];
|
|
1523
1542
|
var POPUP_STYLE_ID = "zenit-leaflet-popup-styles";
|
|
1524
1543
|
var DESKTOP_POPUP_DIMENSIONS = { maxWidth: 350, minWidth: 280, maxHeight: 480 };
|
|
1525
1544
|
var MOBILE_POPUP_DIMENSIONS = { maxWidth: 280, minWidth: 240, maxHeight: 380 };
|
|
@@ -1546,6 +1565,7 @@ var ZENIT_LEAFLET_POPUP_STYLES = `
|
|
|
1546
1565
|
line-height: 1.5;
|
|
1547
1566
|
color: #374151;
|
|
1548
1567
|
min-width: 100%;
|
|
1568
|
+
max-height: min(70vh, 480px);
|
|
1549
1569
|
overflow-y: auto;
|
|
1550
1570
|
overflow-x: hidden;
|
|
1551
1571
|
scrollbar-width: thin;
|
|
@@ -1596,6 +1616,20 @@ var ZENIT_LEAFLET_POPUP_STYLES = `
|
|
|
1596
1616
|
padding: 16px;
|
|
1597
1617
|
}
|
|
1598
1618
|
|
|
1619
|
+
.zenit-popup-header {
|
|
1620
|
+
padding-bottom: 12px;
|
|
1621
|
+
border-bottom: 1px solid #e5e7eb;
|
|
1622
|
+
margin-bottom: 4px;
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
.zenit-popup-title {
|
|
1626
|
+
font-size: 14px;
|
|
1627
|
+
font-weight: 700;
|
|
1628
|
+
color: #111827;
|
|
1629
|
+
letter-spacing: 0.01em;
|
|
1630
|
+
line-height: 1.4;
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1599
1633
|
/* Individual row styling with subtle separator */
|
|
1600
1634
|
.zenit-popup-row {
|
|
1601
1635
|
display: flex;
|
|
@@ -1634,6 +1668,16 @@ var ZENIT_LEAFLET_POPUP_STYLES = `
|
|
|
1634
1668
|
line-height: 1.5;
|
|
1635
1669
|
}
|
|
1636
1670
|
|
|
1671
|
+
.zenit-popup-link {
|
|
1672
|
+
color: #2563eb;
|
|
1673
|
+
text-decoration: underline;
|
|
1674
|
+
font-weight: 500;
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
.zenit-popup-link:hover {
|
|
1678
|
+
color: #1d4ed8;
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1637
1681
|
/* Special styling for description field */
|
|
1638
1682
|
.zenit-popup-row.zenit-popup-description {
|
|
1639
1683
|
background-color: #f9fafb;
|
|
@@ -1728,6 +1772,18 @@ var ZENIT_LEAFLET_POPUP_STYLES = `
|
|
|
1728
1772
|
padding: 12px;
|
|
1729
1773
|
}
|
|
1730
1774
|
|
|
1775
|
+
.zenit-leaflet-popup .leaflet-popup-content {
|
|
1776
|
+
max-height: min(65vh, 380px);
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
.zenit-popup-header {
|
|
1780
|
+
padding-bottom: 10px;
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
.zenit-popup-title {
|
|
1784
|
+
font-size: 13px;
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1731
1787
|
.zenit-popup-row {
|
|
1732
1788
|
padding: 8px 0;
|
|
1733
1789
|
}
|
|
@@ -1776,6 +1832,17 @@ var ZENIT_LEAFLET_POPUP_STYLES = `
|
|
|
1776
1832
|
.zenit-map-tooltip::before {
|
|
1777
1833
|
border-top-color: rgba(31, 41, 55, 0.95);
|
|
1778
1834
|
}
|
|
1835
|
+
|
|
1836
|
+
.polygon-label-tooltip {
|
|
1837
|
+
z-index: 600 !important;
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
.zenit-map-shell.popup-open .zenit-label-marker,
|
|
1841
|
+
.zenit-map-shell.popup-open .polygon-label-tooltip,
|
|
1842
|
+
.zenit-map-shell.popup-open .click-for-detail-hint,
|
|
1843
|
+
.zenit-map-shell.popup-open .zenit-map-tooltip {
|
|
1844
|
+
display: none !important;
|
|
1845
|
+
}
|
|
1779
1846
|
`;
|
|
1780
1847
|
function ensurePopupStyles() {
|
|
1781
1848
|
if (typeof document === "undefined") return;
|
|
@@ -1822,6 +1889,31 @@ function renderPopupValue(value) {
|
|
|
1822
1889
|
if (value === null || value === void 0) {
|
|
1823
1890
|
return '<span class="zenit-popup-empty">Sin datos</span>';
|
|
1824
1891
|
}
|
|
1892
|
+
if (value instanceof Date) {
|
|
1893
|
+
return `<span>${escapeHtml(value.toLocaleDateString("es-GT"))}</span>`;
|
|
1894
|
+
}
|
|
1895
|
+
if (typeof value === "number") {
|
|
1896
|
+
return `<span>${escapeHtml(value.toLocaleString("es-GT"))}</span>`;
|
|
1897
|
+
}
|
|
1898
|
+
if (typeof value === "string") {
|
|
1899
|
+
const trimmed = value.trim();
|
|
1900
|
+
const isLikelyDate = /^\d{4}-\d{2}-\d{2}/.test(trimmed) || trimmed.includes("T");
|
|
1901
|
+
if (isLikelyDate) {
|
|
1902
|
+
const parsed = Date.parse(trimmed);
|
|
1903
|
+
if (!Number.isNaN(parsed)) {
|
|
1904
|
+
return `<span>${escapeHtml(new Date(parsed).toLocaleDateString("es-GT"))}</span>`;
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
try {
|
|
1908
|
+
const parsedUrl = new URL(trimmed);
|
|
1909
|
+
if (parsedUrl.protocol === "http:" || parsedUrl.protocol === "https:") {
|
|
1910
|
+
const safeHref = escapeHtml(parsedUrl.toString());
|
|
1911
|
+
return `<a class="zenit-popup-link" href="${safeHref}" target="_blank" rel="noopener noreferrer">${safeHref}</a>`;
|
|
1912
|
+
}
|
|
1913
|
+
} catch {
|
|
1914
|
+
}
|
|
1915
|
+
return `<span>${escapeHtml(trimmed || value)}</span>`;
|
|
1916
|
+
}
|
|
1825
1917
|
if (typeof value === "object") {
|
|
1826
1918
|
const json = safeJsonStringify(value);
|
|
1827
1919
|
return `<pre class="zenit-popup-pre">${escapeHtml(json)}</pre>`;
|
|
@@ -1842,13 +1934,29 @@ function isDescriptionKey(key) {
|
|
|
1842
1934
|
const normalized = key.trim().toLowerCase();
|
|
1843
1935
|
return DESCRIPTION_KEYS.has(normalized);
|
|
1844
1936
|
}
|
|
1937
|
+
function extractPopupHeader(properties) {
|
|
1938
|
+
if (!properties) return null;
|
|
1939
|
+
const entry = Object.entries(properties).find(
|
|
1940
|
+
(candidate) => {
|
|
1941
|
+
const [key, value] = candidate;
|
|
1942
|
+
return POPUP_HEADER_KEYS.includes(key.trim().toLowerCase()) && typeof value === "string" && value.trim().length > 0;
|
|
1943
|
+
}
|
|
1944
|
+
);
|
|
1945
|
+
if (!entry) return null;
|
|
1946
|
+
return entry[1].trim();
|
|
1947
|
+
}
|
|
1845
1948
|
function formatLabel(key) {
|
|
1846
1949
|
return key.replace(/_/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").trim();
|
|
1847
1950
|
}
|
|
1848
1951
|
function createPopupContent(properties) {
|
|
1849
|
-
const
|
|
1850
|
-
|
|
1851
|
-
|
|
1952
|
+
const headerText = extractPopupHeader(properties);
|
|
1953
|
+
const entries = Object.entries(properties).filter(([key, value]) => {
|
|
1954
|
+
if (!shouldIncludePopupEntry(key, value)) return false;
|
|
1955
|
+
if (headerText && POPUP_HEADER_KEYS.includes(key.trim().toLowerCase())) {
|
|
1956
|
+
return false;
|
|
1957
|
+
}
|
|
1958
|
+
return true;
|
|
1959
|
+
});
|
|
1852
1960
|
if (entries.length === 0) {
|
|
1853
1961
|
return `<div class="zenit-popup-card"><div class="zenit-popup-empty">Sin datos disponibles</div></div>`;
|
|
1854
1962
|
}
|
|
@@ -1876,7 +1984,10 @@ function createPopupContent(properties) {
|
|
|
1876
1984
|
</div>
|
|
1877
1985
|
`;
|
|
1878
1986
|
}).join("");
|
|
1879
|
-
|
|
1987
|
+
const headerHtml = headerText ? `<div class="zenit-popup-header"><div class="zenit-popup-title">${escapeHtml(
|
|
1988
|
+
headerText
|
|
1989
|
+
)}</div></div>` : "";
|
|
1990
|
+
return `<div class="zenit-popup-card">${headerHtml}${rowsHtml}</div>`;
|
|
1880
1991
|
}
|
|
1881
1992
|
function withAlpha(color, alpha) {
|
|
1882
1993
|
const trimmed = color.trim();
|
|
@@ -2101,6 +2212,7 @@ var ZenitMap = (0, import_react.forwardRef)(({
|
|
|
2101
2212
|
const [mapInstance, setMapInstance] = (0, import_react.useState)(null);
|
|
2102
2213
|
const [panesReady, setPanesReady] = (0, import_react.useState)(false);
|
|
2103
2214
|
const [currentZoom, setCurrentZoom] = (0, import_react.useState)(initialZoom ?? DEFAULT_ZOOM);
|
|
2215
|
+
const [isPopupOpen, setIsPopupOpen] = (0, import_react.useState)(false);
|
|
2104
2216
|
const [isMobile, setIsMobile] = (0, import_react.useState)(() => {
|
|
2105
2217
|
if (typeof window === "undefined") return false;
|
|
2106
2218
|
return window.matchMedia("(max-width: 768px)").matches;
|
|
@@ -2129,6 +2241,31 @@ var ZenitMap = (0, import_react.forwardRef)(({
|
|
|
2129
2241
|
ensurePopupStyles();
|
|
2130
2242
|
}
|
|
2131
2243
|
}, [featureInfoMode]);
|
|
2244
|
+
(0, import_react.useEffect)(() => {
|
|
2245
|
+
if (featureInfoMode !== "popup") {
|
|
2246
|
+
setIsPopupOpen(false);
|
|
2247
|
+
}
|
|
2248
|
+
}, [featureInfoMode]);
|
|
2249
|
+
(0, import_react.useEffect)(() => {
|
|
2250
|
+
if (!mapInstance) return;
|
|
2251
|
+
const popupPane = mapInstance.getPane("popupPane");
|
|
2252
|
+
if (popupPane) {
|
|
2253
|
+
popupPane.style.zIndex = "800";
|
|
2254
|
+
}
|
|
2255
|
+
const labelsPane = mapInstance.getPane(LABELS_PANE_NAME) ?? mapInstance.createPane(LABELS_PANE_NAME);
|
|
2256
|
+
labelsPane.style.zIndex = "600";
|
|
2257
|
+
}, [mapInstance]);
|
|
2258
|
+
(0, import_react.useEffect)(() => {
|
|
2259
|
+
if (!mapInstance) return;
|
|
2260
|
+
const handlePopupOpen = () => setIsPopupOpen(true);
|
|
2261
|
+
const handlePopupClose = () => setIsPopupOpen(false);
|
|
2262
|
+
mapInstance.on("popupopen", handlePopupOpen);
|
|
2263
|
+
mapInstance.on("popupclose", handlePopupClose);
|
|
2264
|
+
return () => {
|
|
2265
|
+
mapInstance.off("popupopen", handlePopupOpen);
|
|
2266
|
+
mapInstance.off("popupclose", handlePopupClose);
|
|
2267
|
+
};
|
|
2268
|
+
}, [mapInstance]);
|
|
2132
2269
|
const layerStyleIndex = (0, import_react.useMemo)(() => {
|
|
2133
2270
|
const index = /* @__PURE__ */ new Map();
|
|
2134
2271
|
(map?.mapLayers ?? []).forEach((entry) => {
|
|
@@ -2420,15 +2557,13 @@ var ZenitMap = (0, import_react.forwardRef)(({
|
|
|
2420
2557
|
const baseZIndex = 400;
|
|
2421
2558
|
targetLayers.forEach((layer) => {
|
|
2422
2559
|
const order = Number.isFinite(layer.displayOrder) ? layer.displayOrder : 0;
|
|
2560
|
+
const orderOffset = Math.max(0, Math.min(order, 150));
|
|
2423
2561
|
const fillPaneName = `zenit-layer-${layer.layerId}-fill`;
|
|
2424
2562
|
const pointPaneName = `zenit-layer-${layer.layerId}-points`;
|
|
2425
|
-
const labelPaneName = `zenit-layer-${layer.layerId}-labels`;
|
|
2426
2563
|
const fillPane = targetMap.getPane(fillPaneName) ?? targetMap.createPane(fillPaneName);
|
|
2427
2564
|
const pointPane = targetMap.getPane(pointPaneName) ?? targetMap.createPane(pointPaneName);
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
pointPane.style.zIndex = String(baseZIndex + order + 1e3);
|
|
2431
|
-
labelPane.style.zIndex = String(baseZIndex + order + 2e3);
|
|
2565
|
+
fillPane.style.zIndex = String(baseZIndex + orderOffset);
|
|
2566
|
+
pointPane.style.zIndex = String(baseZIndex + orderOffset + 100);
|
|
2432
2567
|
});
|
|
2433
2568
|
},
|
|
2434
2569
|
[]
|
|
@@ -2455,8 +2590,9 @@ var ZenitMap = (0, import_react.forwardRef)(({
|
|
|
2455
2590
|
}));
|
|
2456
2591
|
ensureLayerPanes(mapInstance, layerTargets);
|
|
2457
2592
|
const first = layerTargets[0];
|
|
2458
|
-
const testPane = mapInstance.getPane(`zenit-layer-${first.layerId}-
|
|
2459
|
-
|
|
2593
|
+
const testPane = mapInstance.getPane(`zenit-layer-${first.layerId}-fill`);
|
|
2594
|
+
const labelsPane = mapInstance.getPane(LABELS_PANE_NAME);
|
|
2595
|
+
if (testPane && labelsPane) {
|
|
2460
2596
|
setPanesReady(true);
|
|
2461
2597
|
}
|
|
2462
2598
|
}, [mapInstance, orderedLayers, ensureLayerPanes]);
|
|
@@ -2481,7 +2617,7 @@ var ZenitMap = (0, import_react.forwardRef)(({
|
|
|
2481
2617
|
maxWidth,
|
|
2482
2618
|
minWidth,
|
|
2483
2619
|
maxHeight,
|
|
2484
|
-
className: "zenit-leaflet-popup",
|
|
2620
|
+
className: "zenit-leaflet-popup custom-leaflet-popup",
|
|
2485
2621
|
autoPan: true,
|
|
2486
2622
|
closeButton: true,
|
|
2487
2623
|
keepInView: true,
|
|
@@ -2506,7 +2642,8 @@ var ZenitMap = (0, import_react.forwardRef)(({
|
|
|
2506
2642
|
id: layerId,
|
|
2507
2643
|
geometry: feature.geometry
|
|
2508
2644
|
}).then((response) => {
|
|
2509
|
-
const
|
|
2645
|
+
const geo = extractGeoJsonFeatureCollection(response);
|
|
2646
|
+
const candidates = geo?.features ?? [];
|
|
2510
2647
|
const resolved = pickIntersectFeature(feature, candidates);
|
|
2511
2648
|
if (!resolved?.properties) return;
|
|
2512
2649
|
const mergedProperties = {
|
|
@@ -2709,87 +2846,93 @@ var ZenitMap = (0, import_react.forwardRef)(({
|
|
|
2709
2846
|
boxSizing: "border-box"
|
|
2710
2847
|
},
|
|
2711
2848
|
children: [
|
|
2712
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2713
|
-
|
|
2849
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2850
|
+
"div",
|
|
2714
2851
|
{
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_leaflet.ZoomControl, { position: "topright" }),
|
|
2729
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(MapInstanceBridge, { onReady: handleMapReady }),
|
|
2730
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FitToBounds, { bbox: explicitZoomBBox ?? void 0 }),
|
|
2731
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AutoFitToBounds, { bbox: autoZoomBBox ?? void 0, enabled: !explicitZoomBBox }),
|
|
2732
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ZoomBasedOpacityHandler, { onZoomChange: handleZoomChange }),
|
|
2733
|
-
orderedLayers.map((layerState) => {
|
|
2734
|
-
const baseOpacity = layerState.effective?.baseOpacity ?? layerState.effective?.opacity ?? 1;
|
|
2735
|
-
const fillPaneName = `zenit-layer-${layerState.mapLayer.layerId}-fill`;
|
|
2736
|
-
const pointsPaneName = `zenit-layer-${layerState.mapLayer.layerId}-points`;
|
|
2737
|
-
const labelPaneName = `zenit-layer-${layerState.mapLayer.layerId}-labels`;
|
|
2738
|
-
const layerType = layerState.layer?.layerType ?? layerState.mapLayer.layerType ?? void 0;
|
|
2739
|
-
const data = layerState.data?.features ?? [];
|
|
2740
|
-
const fillFeatures = data.filter(isNonPointGeometry);
|
|
2741
|
-
const pointFeatures = data.filter(isPointGeometry);
|
|
2742
|
-
const fillData = fillFeatures.length > 0 ? buildFeatureCollection(fillFeatures) : null;
|
|
2743
|
-
const pointsData = pointFeatures.length > 0 ? buildFeatureCollection(pointFeatures) : null;
|
|
2744
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.default.Fragment, { children: [
|
|
2745
|
-
fillData && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2746
|
-
import_react_leaflet.GeoJSON,
|
|
2852
|
+
className: `zenit-map-shell${isPopupOpen ? " popup-open" : ""}`,
|
|
2853
|
+
style: { flex: 1, position: "relative" },
|
|
2854
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
2855
|
+
import_react_leaflet.MapContainer,
|
|
2856
|
+
{
|
|
2857
|
+
center,
|
|
2858
|
+
zoom,
|
|
2859
|
+
style: { height: "100%", width: "100%" },
|
|
2860
|
+
scrollWheelZoom: true,
|
|
2861
|
+
zoomControl: false,
|
|
2862
|
+
children: [
|
|
2863
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2864
|
+
import_react_leaflet.TileLayer,
|
|
2747
2865
|
{
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
style: (feature) => buildLayerStyle(layerState.mapLayer.layerId, baseOpacity, feature, layerType),
|
|
2751
|
-
onEachFeature: overlayOnEachFeature
|
|
2866
|
+
url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
|
|
2867
|
+
attribution: "\xA9 OpenStreetMap contributors"
|
|
2752
2868
|
}
|
|
2753
2869
|
),
|
|
2754
|
-
|
|
2870
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_leaflet.ZoomControl, { position: "topright" }),
|
|
2871
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(MapInstanceBridge, { onReady: handleMapReady }),
|
|
2872
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FitToBounds, { bbox: explicitZoomBBox ?? void 0 }),
|
|
2873
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AutoFitToBounds, { bbox: autoZoomBBox ?? void 0, enabled: !explicitZoomBBox }),
|
|
2874
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ZoomBasedOpacityHandler, { onZoomChange: handleZoomChange }),
|
|
2875
|
+
orderedLayers.map((layerState) => {
|
|
2876
|
+
const baseOpacity = layerState.effective?.baseOpacity ?? layerState.effective?.opacity ?? 1;
|
|
2877
|
+
const fillPaneName = `zenit-layer-${layerState.mapLayer.layerId}-fill`;
|
|
2878
|
+
const pointsPaneName = `zenit-layer-${layerState.mapLayer.layerId}-points`;
|
|
2879
|
+
const layerType = layerState.layer?.layerType ?? layerState.mapLayer.layerType ?? void 0;
|
|
2880
|
+
const data = layerState.data?.features ?? [];
|
|
2881
|
+
const fillFeatures = data.filter(isNonPointGeometry);
|
|
2882
|
+
const pointFeatures = data.filter(isPointGeometry);
|
|
2883
|
+
const fillData = fillFeatures.length > 0 ? buildFeatureCollection(fillFeatures) : null;
|
|
2884
|
+
const pointsData = pointFeatures.length > 0 ? buildFeatureCollection(pointFeatures) : null;
|
|
2885
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.default.Fragment, { children: [
|
|
2886
|
+
fillData && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2887
|
+
import_react_leaflet.GeoJSON,
|
|
2888
|
+
{
|
|
2889
|
+
data: fillData,
|
|
2890
|
+
pane: panesReady && mapInstance?.getPane(fillPaneName) ? fillPaneName : void 0,
|
|
2891
|
+
style: (feature) => buildLayerStyle(layerState.mapLayer.layerId, baseOpacity, feature, layerType),
|
|
2892
|
+
onEachFeature: overlayOnEachFeature
|
|
2893
|
+
}
|
|
2894
|
+
),
|
|
2895
|
+
pointsData && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2896
|
+
import_react_leaflet.GeoJSON,
|
|
2897
|
+
{
|
|
2898
|
+
data: pointsData,
|
|
2899
|
+
pane: panesReady && mapInstance?.getPane(pointsPaneName) ? pointsPaneName : void 0,
|
|
2900
|
+
pointToLayer: (feature, latlng) => import_leaflet.default.circleMarker(latlng, {
|
|
2901
|
+
radius: isMobile ? 8 : 6,
|
|
2902
|
+
...buildLayerStyle(layerState.mapLayer.layerId, baseOpacity, feature, layerType)
|
|
2903
|
+
}),
|
|
2904
|
+
onEachFeature: overlayOnEachFeature
|
|
2905
|
+
}
|
|
2906
|
+
),
|
|
2907
|
+
panesReady && mapInstance?.getPane(LABELS_PANE_NAME) ? labelMarkers.filter(
|
|
2908
|
+
(marker) => String(marker.layerId) === String(layerState.mapLayer.layerId)
|
|
2909
|
+
).map((marker) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2910
|
+
import_react_leaflet.Marker,
|
|
2911
|
+
{
|
|
2912
|
+
position: marker.position,
|
|
2913
|
+
icon: buildLabelIcon(marker.label, marker.opacity, marker.color),
|
|
2914
|
+
interactive: false,
|
|
2915
|
+
pane: LABELS_PANE_NAME
|
|
2916
|
+
},
|
|
2917
|
+
marker.key
|
|
2918
|
+
)) : null
|
|
2919
|
+
] }, layerState.mapLayer.layerId.toString());
|
|
2920
|
+
}),
|
|
2921
|
+
overlayGeojson && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2755
2922
|
import_react_leaflet.GeoJSON,
|
|
2756
2923
|
{
|
|
2757
|
-
data:
|
|
2758
|
-
|
|
2759
|
-
pointToLayer: (feature, latlng) => import_leaflet.default.circleMarker(latlng, {
|
|
2760
|
-
radius: isMobile ? 8 : 6,
|
|
2761
|
-
...buildLayerStyle(layerState.mapLayer.layerId, baseOpacity, feature, layerType)
|
|
2762
|
-
}),
|
|
2924
|
+
data: overlayGeojson,
|
|
2925
|
+
style: overlayStyleFunction,
|
|
2763
2926
|
onEachFeature: overlayOnEachFeature
|
|
2764
|
-
}
|
|
2765
|
-
),
|
|
2766
|
-
panesReady && mapInstance?.getPane(labelPaneName) ? labelMarkers.filter(
|
|
2767
|
-
(marker) => String(marker.layerId) === String(layerState.mapLayer.layerId)
|
|
2768
|
-
).map((marker) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2769
|
-
import_react_leaflet.Marker,
|
|
2770
|
-
{
|
|
2771
|
-
position: marker.position,
|
|
2772
|
-
icon: buildLabelIcon(marker.label, marker.opacity, marker.color),
|
|
2773
|
-
interactive: false,
|
|
2774
|
-
pane: labelPaneName
|
|
2775
2927
|
},
|
|
2776
|
-
|
|
2777
|
-
)
|
|
2778
|
-
]
|
|
2779
|
-
}
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
style: overlayStyleFunction,
|
|
2785
|
-
onEachFeature: overlayOnEachFeature
|
|
2786
|
-
},
|
|
2787
|
-
"zenit-overlay-geojson"
|
|
2788
|
-
)
|
|
2789
|
-
]
|
|
2790
|
-
},
|
|
2791
|
-
String(mapId)
|
|
2792
|
-
) }),
|
|
2928
|
+
"zenit-overlay-geojson"
|
|
2929
|
+
)
|
|
2930
|
+
]
|
|
2931
|
+
},
|
|
2932
|
+
String(mapId)
|
|
2933
|
+
)
|
|
2934
|
+
}
|
|
2935
|
+
),
|
|
2793
2936
|
showLayerPanel && decoratedLayers.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
2794
2937
|
"div",
|
|
2795
2938
|
{
|