Persist map flags and toggle selected parcels

This commit is contained in:
livio committed 2026-09-22 14:43:27 +02:00
1 parent e93dd9b867
commit ce677e3f42
5 files changed
+151 -26

No files matched your search

+119 -22
View File
@@ -58,8 +58,15 @@
</span> </span>
</label> </label>
} }
<label class="map-layer-option">
<input type="checkbox" @bind="ShowSelectedParcels" @bind:after="ApplySelectedParcelsVisibility" />
<span>
<strong>Particelle selezionate</strong>
<small>Nascondi o mostra senza eliminare i dati</small>
</span>
</label>
<div class="layer-panel-actions"> <div class="layer-panel-actions">
<button class="secondary-command" @onclick="ClearSelectedParcels">Rimuovi particelle selezionate</button> <button class="danger-command" @onclick="ClearSelectedParcels">Elimina definitivamente le particelle selezionate</button>
<button class="danger-command" @onclick="ClearMapElements">Pulisci elementi mappa</button> <button class="danger-command" @onclick="ClearMapElements">Pulisci elementi mappa</button>
</div> </div>
</section> </section>
@@ -175,7 +182,7 @@
</label> </label>
<small class="field-help">La cornice grande resta separata dalle particelle e puo essere nascosta anche nei progetti salvati.</small> <small class="field-help">La cornice grande resta separata dalle particelle e puo essere nascosta anche nei progetti salvati.</small>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" checked="@ShowImportedMeasurements" @onchange="ToggleImportedMeasurements" /> <input type="checkbox" @bind="ShowImportedMeasurements" @bind:after="ApplyImportedMeasurementsVisibility" />
<span>Mostra misure dei file caricati</span> <span>Mostra misure dei file caricati</span>
</label> </label>
<div class="button-row"> <div class="button-row">
@@ -187,7 +194,7 @@
<section class="panel-section"> <section class="panel-section">
<h2>Disegni e misure</h2> <h2>Disegni e misure</h2>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" checked="@ShowDrawingMeasurements" @onchange="ToggleDrawingMeasurements" /> <input type="checkbox" @bind="ShowDrawingMeasurements" @bind:after="ApplyDrawingMeasurementsVisibility" />
<span>Mostra superficie, perimetro e lati</span> <span>Mostra superficie, perimetro e lati</span>
</label> </label>
<button class="secondary-command" aria-pressed="@DrawToolsVisible" @onclick="ToggleDrawTools"> <button class="secondary-command" aria-pressed="@DrawToolsVisible" @onclick="ToggleDrawTools">
@@ -225,27 +232,27 @@
</label> </label>
<div class="export-options" role="group" aria-label="Oggetti da esportare"> <div class="export-options" role="group" aria-label="Oggetti da esportare">
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" @bind="ExportImported" /> <input type="checkbox" @bind="ExportImported" @bind:after="SaveFlagPreferences" />
<span>Particelle e dati GIS importati</span> <span>Particelle e dati GIS importati</span>
</label> </label>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" @bind="ExportImportedSheets" /> <input type="checkbox" @bind="ExportImportedSheets" @bind:after="SaveFlagPreferences" />
<span>Cornici, fogli e riquadri KMZ</span> <span>Cornici, fogli e riquadri KMZ</span>
</label> </label>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" @bind="ExportCadastral" /> <input type="checkbox" @bind="ExportCadastral" @bind:after="SaveFlagPreferences" />
<span>Particelle catastali rosse e GPS</span> <span>Particelle catastali rosse e GPS</span>
</label> </label>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" @bind="ExportDrawings" /> <input type="checkbox" @bind="ExportDrawings" @bind:after="SaveFlagPreferences" />
<span>Disegni, aree, linee e cerchi</span> <span>Disegni, aree, linee e cerchi</span>
</label> </label>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" @bind="ExportPoi" /> <input type="checkbox" @bind="ExportPoi" @bind:after="SaveFlagPreferences" />
<span>Punti di interesse</span> <span>Punti di interesse</span>
</label> </label>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" @bind="ExportTrail" /> <input type="checkbox" @bind="ExportTrail" @bind:after="SaveFlagPreferences" />
<span>Traccia GPS registrata</span> <span>Traccia GPS registrata</span>
</label> </label>
</div> </div>
@@ -267,7 +274,7 @@
<input @bind="NewProjectName" @bind:event="oninput" placeholder="Es. Rilievo San Nicola" maxlength="80" /> <input @bind="NewProjectName" @bind:event="oninput" placeholder="Es. Rilievo San Nicola" maxlength="80" />
</label> </label>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" @bind="IncludeCadastralParcels" /> <input type="checkbox" @bind="IncludeCadastralParcels" @bind:after="SaveFlagPreferences" />
<span>Includi le particelle catastali rosse</span> <span>Includi le particelle catastali rosse</span>
</label> </label>
<button class="primary-command" @onclick="SaveProject" disabled="@(ProjectBusy || string.IsNullOrWhiteSpace(NewProjectName))">Salva progetto</button> <button class="primary-command" @onclick="SaveProject" disabled="@(ProjectBusy || string.IsNullOrWhiteSpace(NewProjectName))">Salva progetto</button>
@@ -300,11 +307,11 @@
</label> </label>
<small class="field-help">Il comando agisce subito sulla mappa e sui dati del progetto caricato.</small> <small class="field-help">Il comando agisce subito sulla mappa e sui dati del progetto caricato.</small>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" checked="@ShowImportedMeasurements" @onchange="ToggleImportedMeasurements" /> <input type="checkbox" @bind="ShowImportedMeasurements" @bind:after="ApplyImportedMeasurementsVisibility" />
<span>Mostra misure dei file caricati</span> <span>Mostra misure dei file caricati</span>
</label> </label>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" checked="@ShowDrawingMeasurements" @onchange="ToggleDrawingMeasurements" /> <input type="checkbox" @bind="ShowDrawingMeasurements" @bind:after="ApplyDrawingMeasurementsVisibility" />
<span>Mostra misure dei disegni</span> <span>Mostra misure dei disegni</span>
</label> </label>
</section> </section>
@@ -357,11 +364,11 @@
<section class="panel-section"> <section class="panel-section">
<h2>GPS e percorso</h2> <h2>GPS e percorso</h2>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" checked="@ShowGpsPosition" @onchange="ToggleGpsPosition" /> <input type="checkbox" @bind="ShowGpsPosition" @bind:after="ApplyGpsPositionVisibility" />
<span>Mostra punto e cerchio GPS</span> <span>Mostra punto e cerchio GPS</span>
</label> </label>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" checked="@TrailEnabled" @onchange="ToggleTrail" /> <input type="checkbox" @bind="TrailEnabled" @bind:after="ApplyTrailOption" />
<span>Registra la traccia mentre cammini</span> <span>Registra la traccia mentre cammini</span>
</label> </label>
</section> </section>
@@ -415,6 +422,7 @@
</div> </div>
@code { @code {
private const string FlagPreferencePrefix = "lme_flag_";
private string ActiveTab { get; set; } = "map"; private string ActiveTab { get; set; } = "map";
private string SearchText { get; set; } = string.Empty; private string SearchText { get; set; } = string.Empty;
private string NewProjectName { get; set; } = string.Empty; private string NewProjectName { get; set; } = string.Empty;
@@ -437,6 +445,7 @@
private bool CatalogBusy { get; set; } private bool CatalogBusy { get; set; }
private bool GpsActive { get; set; } private bool GpsActive { get; set; }
private bool ShowGpsPosition { get; set; } = true; private bool ShowGpsPosition { get; set; } = true;
private bool ShowSelectedParcels { get; set; } = true;
private bool DrawToolsVisible { get; set; } private bool DrawToolsVisible { get; set; }
private bool TrailEnabled { get; set; } private bool TrailEnabled { get; set; }
private bool LayerPanelOpen { get; set; } private bool LayerPanelOpen { get; set; }
@@ -502,6 +511,8 @@
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
LoadFlagPreferences();
try try
{ {
GoogleMapsApiKey = await SecureStorage.Default.GetAsync("google_maps_api_key") ?? string.Empty; GoogleMapsApiKey = await SecureStorage.Default.GetAsync("google_maps_api_key") ?? string.Empty;
@@ -537,6 +548,7 @@
if (firstRender) if (firstRender)
{ {
await JS.InvokeVoidAsync("lmeMap.init"); await JS.InvokeVoidAsync("lmeMap.init");
await ApplyFlagPreferencesToMapAsync();
await CenterOnInitialLocationAsync(); await CenterOnInitialLocationAsync();
await MigrateLegacyProjectAsync(); await MigrateLegacyProjectAsync();
} }
@@ -854,9 +866,9 @@
} }
} }
private async Task ToggleGpsPosition(ChangeEventArgs args) private async Task ApplyGpsPositionVisibility()
{ {
ShowGpsPosition = (bool?)args.Value == true; SaveFlagPreferences();
await JS.InvokeVoidAsync("lmeMap.setGpsPositionVisible", ShowGpsPosition); await JS.InvokeVoidAsync("lmeMap.setGpsPositionVisible", ShowGpsPosition);
} }
@@ -969,6 +981,7 @@
private async Task ClearImportedLayers() private async Task ClearImportedLayers()
{ {
ShowImportedSheetLayer = false; ShowImportedSheetLayer = false;
SaveFlagPreferences();
await JS.InvokeVoidAsync("lmeMap.clearImported"); await JS.InvokeVoidAsync("lmeMap.clearImported");
} }
private Task AddProjectMarker() => JS.InvokeVoidAsync("lmeMap.addProjectMarker", PoiName).AsTask(); private Task AddProjectMarker() => JS.InvokeVoidAsync("lmeMap.addProjectMarker", PoiName).AsTask();
@@ -976,30 +989,33 @@
private async Task ApplyKmlSheetLayerOption() private async Task ApplyKmlSheetLayerOption()
{ {
ShowImportedSheetLayer = IncludeKmlSheetLayer; ShowImportedSheetLayer = IncludeKmlSheetLayer;
SaveFlagPreferences();
await JS.InvokeVoidAsync("lmeMap.setIncludeKmlSheetLayer", IncludeKmlSheetLayer); await JS.InvokeVoidAsync("lmeMap.setIncludeKmlSheetLayer", IncludeKmlSheetLayer);
await JS.InvokeVoidAsync("lmeMap.setImportedSheetLayerVisible", ShowImportedSheetLayer); await JS.InvokeVoidAsync("lmeMap.setImportedSheetLayerVisible", ShowImportedSheetLayer);
} }
private Task ApplyImportedSheetLayerVisibility() private Task ApplyImportedSheetLayerVisibility()
{ {
SaveFlagPreferences();
return JS.InvokeVoidAsync("lmeMap.setImportedSheetLayerVisible", ShowImportedSheetLayer).AsTask(); return JS.InvokeVoidAsync("lmeMap.setImportedSheetLayerVisible", ShowImportedSheetLayer).AsTask();
} }
private async Task ToggleImportedMeasurements(ChangeEventArgs args) private async Task ApplyImportedMeasurementsVisibility()
{ {
ShowImportedMeasurements = (bool?)args.Value == true; SaveFlagPreferences();
await JS.InvokeVoidAsync("lmeMap.setImportedMeasurementsVisible", ShowImportedMeasurements); await JS.InvokeVoidAsync("lmeMap.setImportedMeasurementsVisible", ShowImportedMeasurements);
} }
private async Task ToggleDrawingMeasurements(ChangeEventArgs args) private async Task ApplyDrawingMeasurementsVisibility()
{ {
ShowDrawingMeasurements = (bool?)args.Value == true; SaveFlagPreferences();
await JS.InvokeVoidAsync("lmeMap.setDrawingMeasurementsVisible", ShowDrawingMeasurements); await JS.InvokeVoidAsync("lmeMap.setDrawingMeasurementsVisible", ShowDrawingMeasurements);
} }
private async Task ToggleDrawTools() private async Task ToggleDrawTools()
{ {
DrawToolsVisible = !DrawToolsVisible; DrawToolsVisible = !DrawToolsVisible;
SaveFlagPreferences();
await JS.InvokeVoidAsync("lmeMap.setDrawToolsVisible", DrawToolsVisible); await JS.InvokeVoidAsync("lmeMap.setDrawToolsVisible", DrawToolsVisible);
if (DrawToolsVisible) if (DrawToolsVisible)
@@ -1164,6 +1180,7 @@
ShowDrawingMeasurements = options.ShowDrawingMeasurements; ShowDrawingMeasurements = options.ShowDrawingMeasurements;
DrawToolsVisible = options.DrawToolsVisible; DrawToolsVisible = options.DrawToolsVisible;
ShowGpsPosition = options.GpsPositionVisible; ShowGpsPosition = options.GpsPositionVisible;
ShowSelectedParcels = options.SelectedParcelsVisible;
TrailEnabled = options.TrailEnabled; TrailEnabled = options.TrailEnabled;
var activeLayers = (options.CadastreLayers ?? []).ToHashSet(StringComparer.Ordinal); var activeLayers = (options.CadastreLayers ?? []).ToHashSet(StringComparer.Ordinal);
@@ -1171,6 +1188,7 @@
{ {
layer.Enabled = activeLayers.Contains(layer.Key); layer.Enabled = activeLayers.Contains(layer.Key);
} }
SaveFlagPreferences();
} }
private async Task DeleteProject() private async Task DeleteProject()
@@ -1203,9 +1221,9 @@
} }
} }
private Task CenterOnGps() => JS.InvokeVoidAsync("lmeMap.centerOnGps").AsTask(); private Task CenterOnGps() => JS.InvokeVoidAsync("lmeMap.centerOnGps").AsTask();
private async Task ToggleTrail(ChangeEventArgs args) private async Task ApplyTrailOption()
{ {
TrailEnabled = (bool?)args.Value == true; SaveFlagPreferences();
await JS.InvokeVoidAsync("lmeMap.toggleTrail", TrailEnabled); await JS.InvokeVoidAsync("lmeMap.toggleTrail", TrailEnabled);
} }
private async Task ChangeBaseLayer(ChangeEventArgs args) private async Task ChangeBaseLayer(ChangeEventArgs args)
@@ -1310,9 +1328,87 @@
private async Task ToggleCadastreLayer(CadastralLayer layer, ChangeEventArgs args) private async Task ToggleCadastreLayer(CadastralLayer layer, ChangeEventArgs args)
{ {
layer.Enabled = args.Value is true; layer.Enabled = args.Value is true;
SaveFlagPreferences();
await JS.InvokeVoidAsync("lmeMap.toggleCadastreLayer", layer.Key, layer.Enabled); await JS.InvokeVoidAsync("lmeMap.toggleCadastreLayer", layer.Key, layer.Enabled);
} }
private void LoadFlagPreferences()
{
IncludeCadastralParcels = GetFlagPreference("include_cadastral_parcels", true);
IncludeKmlSheetLayer = GetFlagPreference("include_kml_sheet_layer", false);
ShowImportedSheetLayer = GetFlagPreference("show_imported_sheet_layer", false);
ShowImportedMeasurements = GetFlagPreference("show_imported_measurements", false);
ShowDrawingMeasurements = GetFlagPreference("show_drawing_measurements", true);
DrawToolsVisible = GetFlagPreference("draw_tools_visible", false);
ShowGpsPosition = GetFlagPreference("show_gps_position", true);
ShowSelectedParcels = GetFlagPreference("show_selected_parcels", true);
TrailEnabled = GetFlagPreference("trail_enabled", false);
ExportImported = GetFlagPreference("export_imported", true);
ExportImportedSheets = GetFlagPreference("export_imported_sheets", true);
ExportCadastral = GetFlagPreference("export_cadastral", true);
ExportDrawings = GetFlagPreference("export_drawings", true);
ExportPoi = GetFlagPreference("export_poi", true);
ExportTrail = GetFlagPreference("export_trail", true);
foreach (var layer in CadastralLayers)
{
layer.Enabled = GetFlagPreference($"cadastre_layer_{layer.Key}", layer.Enabled);
}
}
private void SaveFlagPreferences()
{
SetFlagPreference("include_cadastral_parcels", IncludeCadastralParcels);
SetFlagPreference("include_kml_sheet_layer", IncludeKmlSheetLayer);
SetFlagPreference("show_imported_sheet_layer", ShowImportedSheetLayer);
SetFlagPreference("show_imported_measurements", ShowImportedMeasurements);
SetFlagPreference("show_drawing_measurements", ShowDrawingMeasurements);
SetFlagPreference("draw_tools_visible", DrawToolsVisible);
SetFlagPreference("show_gps_position", ShowGpsPosition);
SetFlagPreference("show_selected_parcels", ShowSelectedParcels);
SetFlagPreference("trail_enabled", TrailEnabled);
SetFlagPreference("export_imported", ExportImported);
SetFlagPreference("export_imported_sheets", ExportImportedSheets);
SetFlagPreference("export_cadastral", ExportCadastral);
SetFlagPreference("export_drawings", ExportDrawings);
SetFlagPreference("export_poi", ExportPoi);
SetFlagPreference("export_trail", ExportTrail);
foreach (var layer in CadastralLayers)
{
SetFlagPreference($"cadastre_layer_{layer.Key}", layer.Enabled);
}
}
private async Task ApplyFlagPreferencesToMapAsync()
{
await JS.InvokeVoidAsync("lmeMap.setIncludeKmlSheetLayer", IncludeKmlSheetLayer);
await JS.InvokeVoidAsync("lmeMap.setImportedSheetLayerVisible", ShowImportedSheetLayer);
await JS.InvokeVoidAsync("lmeMap.setImportedMeasurementsVisible", ShowImportedMeasurements);
await JS.InvokeVoidAsync("lmeMap.setDrawingMeasurementsVisible", ShowDrawingMeasurements);
await JS.InvokeVoidAsync("lmeMap.setDrawToolsVisible", DrawToolsVisible);
await JS.InvokeVoidAsync("lmeMap.setGpsPositionVisible", ShowGpsPosition);
await JS.InvokeVoidAsync("lmeMap.setSelectedParcelsVisible", ShowSelectedParcels);
await JS.InvokeVoidAsync("lmeMap.toggleTrail", TrailEnabled);
foreach (var layer in CadastralLayers)
{
await JS.InvokeVoidAsync("lmeMap.toggleCadastreLayer", layer.Key, layer.Enabled);
}
}
private static bool GetFlagPreference(string name, bool defaultValue) =>
Preferences.Default.Get($"{FlagPreferencePrefix}{name}", defaultValue);
private static void SetFlagPreference(string name, bool value) =>
Preferences.Default.Set($"{FlagPreferencePrefix}{name}", value);
private async Task ApplySelectedParcelsVisibility()
{
SaveFlagPreferences();
await JS.InvokeVoidAsync("lmeMap.setSelectedParcelsVisible", ShowSelectedParcels);
}
private async Task ExportCadastralImage() private async Task ExportCadastralImage()
{ {
ActiveTab = "map"; ActiveTab = "map";
@@ -1351,6 +1447,7 @@
public bool ShowDrawingMeasurements { get; init; } = true; public bool ShowDrawingMeasurements { get; init; } = true;
public bool DrawToolsVisible { get; init; } public bool DrawToolsVisible { get; init; }
public bool GpsPositionVisible { get; init; } = true; public bool GpsPositionVisible { get; init; } = true;
public bool SelectedParcelsVisible { get; init; } = true;
public bool TrailEnabled { get; init; } public bool TrailEnabled { get; init; }
} }
+2 -2
View File
@@ -28,8 +28,8 @@
<ApplicationId>com.companyname.lmemappecatastaliapp</ApplicationId> <ApplicationId>com.companyname.lmemappecatastaliapp</ApplicationId>
<!-- Versions --> <!-- Versions -->
<ApplicationDisplayVersion>0.2.16</ApplicationDisplayVersion> <ApplicationDisplayVersion>0.2.17</ApplicationDisplayVersion>
<ApplicationVersion>20</ApplicationVersion> <ApplicationVersion>21</ApplicationVersion>
<!-- To develop, package, and publish an app to the Microsoft Store, see: https://aka.ms/MauiTemplateUnpackaged --> <!-- To develop, package, and publish an app to the Microsoft Store, see: https://aka.ms/MauiTemplateUnpackaged -->
<WindowsPackageType>None</WindowsPackageType> <WindowsPackageType>None</WindowsPackageType>
+1 -1
View File
@@ -13,7 +13,7 @@ public sealed class AzureMapsService
public AzureMapsService() public AzureMapsService()
{ {
_httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("LMEMappeCatastali/0.2.16"); _httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("LMEMappeCatastali/0.2.17");
_httpClient.DefaultRequestHeaders.Accept.ParseAdd("application/json"); _httpClient.DefaultRequestHeaders.Accept.ParseAdd("application/json");
} }
+1 -1
View File
@@ -13,7 +13,7 @@ public sealed class NetworkLocationService
public NetworkLocationService() public NetworkLocationService()
{ {
httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("LMEMappeCatastali/0.2.16"); httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("LMEMappeCatastali/0.2.17");
} }
public async Task<NetworkLocationSnapshot?> GetApproximateLocationAsync( public async Task<NetworkLocationSnapshot?> GetApproximateLocationAsync(
+28
View File
@@ -26,6 +26,7 @@ const lmeState = {
lastAccuracy: 0, lastAccuracy: 0,
gpsTrail: null, gpsTrail: null,
selectedParcelsLayer: null, selectedParcelsLayer: null,
selectedParcelsVisible: true,
gpsParcelLayer: null, gpsParcelLayer: null,
gpsTrailEnabled: false, gpsTrailEnabled: false,
gpsTrailPoints: [], gpsTrailPoints: [],
@@ -50,6 +51,7 @@ window.lmeMap = {
exportCadastreView, exportCadastreView,
closeCadastrePreview, closeCadastrePreview,
clearSelectedParcels, clearSelectedParcels,
setSelectedParcelsVisible,
clearMapElements, clearMapElements,
fitImported, fitImported,
clearImported, clearImported,
@@ -1701,6 +1703,7 @@ function captureDisplayOptions() {
showDrawingMeasurements: lmeState.showDrawingMeasurements, showDrawingMeasurements: lmeState.showDrawingMeasurements,
drawToolsVisible: Boolean(lmeState.drawControl), drawToolsVisible: Boolean(lmeState.drawControl),
gpsPositionVisible: lmeState.gpsPositionVisible, gpsPositionVisible: lmeState.gpsPositionVisible,
selectedParcelsVisible: lmeState.selectedParcelsVisible,
trailEnabled: lmeState.gpsTrailEnabled trailEnabled: lmeState.gpsTrailEnabled
}; };
} }
@@ -1733,6 +1736,7 @@ function applyProjectDisplayOptions(options) {
setBaseLayer(options.baseLayer); setBaseLayer(options.baseLayer);
} }
setGpsPositionVisible(options.gpsPositionVisible !== false); setGpsPositionVisible(options.gpsPositionVisible !== false);
setSelectedParcelsVisible(options.selectedParcelsVisible !== false);
toggleTrail(Boolean(options.trailEnabled)); toggleTrail(Boolean(options.trailEnabled));
setDrawToolsVisible(Boolean(options.drawToolsVisible)); setDrawToolsVisible(Boolean(options.drawToolsVisible));
} }
@@ -2066,6 +2070,30 @@ function clearSelectedParcels() {
setInfo(count ? `${count} particelle selezionate rimosse.` : "Non ci sono particelle selezionate da rimuovere."); setInfo(count ? `${count} particelle selezionate rimosse.` : "Non ci sono particelle selezionate da rimuovere.");
} }
function setSelectedParcelsVisible(enabled) {
lmeState.selectedParcelsVisible = Boolean(enabled);
if (!lmeState.map || !lmeState.selectedParcelsLayer) {
return;
}
if (lmeState.selectedParcelsVisible) {
if (!lmeState.map.hasLayer(lmeState.selectedParcelsLayer)) {
lmeState.selectedParcelsLayer.addTo(lmeState.map);
}
lmeState.selectedParcelsLayer.bringToFront();
const count = lmeState.selectedParcelsLayer.toGeoJSON().features?.length || 0;
setInfo(count
? `${count} particelle selezionate visibili.`
: "Nessuna particella selezionata da mostrare.");
return;
}
if (lmeState.map.hasLayer(lmeState.selectedParcelsLayer)) {
lmeState.map.removeLayer(lmeState.selectedParcelsLayer);
}
setInfo("Particelle selezionate nascoste; i dati restano nel progetto.");
}
function clearMapElements() { function clearMapElements() {
const count = lmeState.selectedParcelsLayer.getLayers().length const count = lmeState.selectedParcelsLayer.getLayers().length
+ lmeState.gpsParcelLayer.getLayers().length + lmeState.gpsParcelLayer.getLayers().length