Fix imported sheet layer visibility
This commit is contained in:
1 parent
c093d88677
commit
a9b1d74983
4 files changed
+16
-26
No files matched your search
+12
-22
@@ -469,23 +469,9 @@ function bindFileImport() {
|
||||
try {
|
||||
const result = await readGisFile(file);
|
||||
const geojson = result.geojson;
|
||||
const parcelLayer = L.geoJSON(geojson, {
|
||||
style: { color: "#22c55e", weight: 3, opacity: 0.95, fillOpacity: 0.18 },
|
||||
pointToLayer: (feature, latlng) => L.circleMarker(latlng, { radius: 7, color: "#22c55e", fillColor: "#ffffff", fillOpacity: 0.9 }),
|
||||
onEachFeature: (feature, layer) => {
|
||||
const name = feature?.properties?.name || file.name;
|
||||
layer.bindPopup(`<strong>${escapeHtml(name)}</strong>`);
|
||||
}
|
||||
}).addTo(lmeState.imported);
|
||||
const parcelLayer = addImportedFeatures(geojson);
|
||||
const sheetGeojson = result.sheetGeojson || emptyFeatureCollection();
|
||||
const sheetLayer = L.geoJSON(sheetGeojson, {
|
||||
style: { color: "#15803d", weight: 3, opacity: 0.85, fillOpacity: 0.04, dashArray: "9 7" },
|
||||
pointToLayer: (feature, latlng) => L.circleMarker(latlng, { radius: 6, color: "#15803d", fillOpacity: 0.25 }),
|
||||
onEachFeature: (feature, layer) => {
|
||||
const name = feature?.properties?.name || "Foglio catastale importato";
|
||||
layer.bindPopup(`<strong>${escapeHtml(name)}</strong>`);
|
||||
}
|
||||
}).addTo(lmeState.importedSheets);
|
||||
const sheetLayer = addImportedSheetFeatures(sheetGeojson);
|
||||
applyImportedSheetVisibility();
|
||||
fitLayer(geojson.features.length ? parcelLayer : sheetLayer);
|
||||
refreshImportedMeasurements();
|
||||
@@ -904,7 +890,7 @@ function setImportedSheetLayerVisible(enabled) {
|
||||
applyImportedSheetVisibility();
|
||||
const count = lmeState.importedSheets?.toGeoJSON()?.features?.length || 0;
|
||||
setInfo(lmeState.importedSheetsVisible
|
||||
? (count ? `Layer del foglio importato visibile (${count} elementi).` : "Il layer del foglio sara visibile quando verra importato.")
|
||||
? (count ? `Layer del foglio importato visibile (${count} elementi).` : "Nessun layer del foglio importato: ricarica il KML/KMZ con 'includi anche il layer del foglio' attivo.")
|
||||
: "Layer del foglio importato nascosto; le particelle restano visibili.");
|
||||
}
|
||||
|
||||
@@ -942,11 +928,12 @@ function addImportedFeatures(geojson) {
|
||||
|
||||
function addImportedSheetFeatures(geojson) {
|
||||
return L.geoJSON(geojson || emptyFeatureCollection(), {
|
||||
style: { color: "#15803d", weight: 3, opacity: 0.85, fillOpacity: 0.04, dashArray: "9 7" },
|
||||
style: { color: "#f59e0b", weight: 4, opacity: 1, fillOpacity: 0.03, dashArray: "10 6" },
|
||||
pointToLayer: (feature, latlng) => L.circleMarker(latlng, {
|
||||
radius: 6,
|
||||
color: "#15803d",
|
||||
fillOpacity: 0.25
|
||||
radius: 7,
|
||||
color: "#f59e0b",
|
||||
fillColor: "#ffffff",
|
||||
fillOpacity: 0.85
|
||||
}),
|
||||
onEachFeature: bindStoredFeaturePopup
|
||||
}).addTo(lmeState.importedSheets);
|
||||
@@ -960,8 +947,11 @@ function applyImportedSheetVisibility() {
|
||||
if (!lmeState.map.hasLayer(lmeState.importedSheets)) {
|
||||
lmeState.importedSheets.addTo(lmeState.map);
|
||||
}
|
||||
lmeState.importedSheets.bringToBack();
|
||||
lmeState.importedSheets.bringToFront();
|
||||
lmeState.imported.bringToFront();
|
||||
lmeState.selectedParcelsLayer.bringToFront();
|
||||
lmeState.gpsParcelLayer.bringToFront();
|
||||
lmeState.drawings.bringToFront();
|
||||
return;
|
||||
}
|
||||
if (lmeState.map.hasLayer(lmeState.importedSheets)) {
|
||||
|
||||
Reference in new issue
Block a user