Improve map measurement tools and project layers
This commit is contained in:
1 parent
0344227a1b
commit
06050b05f5
8 files changed
+396
-156
No files matched your search
+53
-28
@@ -4,6 +4,7 @@
|
||||
@inject CadastralCatalogService CatalogService
|
||||
@inject OfficialCadastreService OfficialCadastreService
|
||||
@inject LocationSearchService LocationSearchService
|
||||
@inject NetworkLocationService NetworkLocationService
|
||||
@inject AzureMapsService AzureMapsService
|
||||
@inject ProjectStorageService ProjectStorageService
|
||||
@implements IAsyncDisposable
|
||||
@@ -11,7 +12,7 @@
|
||||
<PageTitle>LME Mappe Catastali</PageTitle>
|
||||
|
||||
<div class="map-app">
|
||||
<section class="map-stage">
|
||||
<section class="map-stage @(ActiveTab == "search" ? "search-active" : null)">
|
||||
<div id="map"></div>
|
||||
|
||||
<header class="map-toolbar">
|
||||
@@ -72,16 +73,6 @@
|
||||
<button class="gps-center" @onclick="CenterOnGps" aria-label="Centra posizione">Centra</button>
|
||||
</div>
|
||||
|
||||
@if ((ActiveTab is "map" or "search") && !LayerPanelOpen)
|
||||
{
|
||||
<div class="map-measure-tools @(ActiveTab == "search" ? "search-open" : null)" aria-label="Strumenti rapidi di misura">
|
||||
<span>Misura</span>
|
||||
<button title="Disegna e misura un'area" @onclick='() => StartMeasurementDrawing("area")'>Area</button>
|
||||
<button title="Disegna e misura una distanza" @onclick='() => StartMeasurementDrawing("distance")'>Distanza</button>
|
||||
<button title="Disegna e misura un cerchio" @onclick='() => StartMeasurementDrawing("circle")'>Cerchio</button>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (ActiveTab is not "map" and not "search")
|
||||
{
|
||||
<aside class="tool-sheet">
|
||||
@@ -177,6 +168,11 @@
|
||||
? "Attivato: importa foglio, particelle e altri elementi KML/KMZ."
|
||||
: "Disattivato: importa solo i poligoni delle particelle riconosciute.")
|
||||
</small>
|
||||
<label class="toggle-line project-save-option">
|
||||
<input type="checkbox" checked="@ShowImportedSheetLayer" @onchange="ToggleImportedSheetLayer" />
|
||||
<span>Mostra cornice/layer del foglio importato</span>
|
||||
</label>
|
||||
<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">
|
||||
<input type="checkbox" checked="@ShowImportedMeasurements" @onchange="ToggleImportedMeasurements" />
|
||||
<span>Mostra misure dei file caricati</span>
|
||||
@@ -373,6 +369,7 @@
|
||||
private bool LayerPanelOpen { get; set; }
|
||||
private bool IncludeCadastralParcels { get; set; } = true;
|
||||
private bool IncludeKmlSheetLayer { get; set; }
|
||||
private bool ShowImportedSheetLayer { get; set; }
|
||||
private bool ShowImportedMeasurements { get; set; }
|
||||
private bool ShowDrawingMeasurements { get; set; } = true;
|
||||
private bool ProjectBusy { get; set; }
|
||||
@@ -465,13 +462,40 @@
|
||||
|
||||
private async Task CenterOnInitialLocationAsync()
|
||||
{
|
||||
using var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(12));
|
||||
NetworkLocationSnapshot? networkLocation = null;
|
||||
try
|
||||
{
|
||||
var location = await LocationService.GetCurrentLocationAsync(timeout.Token);
|
||||
using var networkTimeout = new CancellationTokenSource(TimeSpan.FromSeconds(8));
|
||||
networkLocation = await NetworkLocationService.GetApproximateLocationAsync(networkTimeout.Token);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// An unavailable IP service must not prevent the GPS fallback.
|
||||
}
|
||||
|
||||
if (networkLocation is not null)
|
||||
{
|
||||
await JS.InvokeVoidAsync(
|
||||
"lmeMap.showInitialPosition",
|
||||
networkLocation.Latitude,
|
||||
networkLocation.Longitude,
|
||||
true,
|
||||
networkLocation.Label);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using var gpsTimeout = new CancellationTokenSource(TimeSpan.FromSeconds(18));
|
||||
var location = await LocationService.GetCurrentLocationAsync(gpsTimeout.Token);
|
||||
if (location is not null)
|
||||
{
|
||||
await JS.InvokeVoidAsync("lmeMap.showInitialPosition", location);
|
||||
await JS.InvokeVoidAsync(
|
||||
"lmeMap.showInitialPosition",
|
||||
location.Latitude,
|
||||
location.Longitude,
|
||||
false,
|
||||
string.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -480,7 +504,7 @@
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
await JS.InvokeVoidAsync("lmeMap.showInfo", "Ricerca della posizione iniziale scaduta. Usa Avvia GPS per riprovare.");
|
||||
await JS.InvokeVoidAsync("lmeMap.showInfo", "Posizione iniziale non disponibile. Usa Avvia GPS per riprovare.");
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
@@ -823,13 +847,25 @@
|
||||
}
|
||||
|
||||
private Task FitImportedLayers() => JS.InvokeVoidAsync("lmeMap.fitImported").AsTask();
|
||||
private Task ClearImportedLayers() => JS.InvokeVoidAsync("lmeMap.clearImported").AsTask();
|
||||
private async Task ClearImportedLayers()
|
||||
{
|
||||
ShowImportedSheetLayer = false;
|
||||
await JS.InvokeVoidAsync("lmeMap.clearImported");
|
||||
}
|
||||
private Task AddProjectMarker() => JS.InvokeVoidAsync("lmeMap.addProjectMarker", PoiName).AsTask();
|
||||
|
||||
private async Task ToggleKmlSheetLayer(ChangeEventArgs args)
|
||||
{
|
||||
IncludeKmlSheetLayer = (bool?)args.Value == true;
|
||||
ShowImportedSheetLayer = IncludeKmlSheetLayer;
|
||||
await JS.InvokeVoidAsync("lmeMap.setIncludeKmlSheetLayer", IncludeKmlSheetLayer);
|
||||
await JS.InvokeVoidAsync("lmeMap.setImportedSheetLayerVisible", ShowImportedSheetLayer);
|
||||
}
|
||||
|
||||
private async Task ToggleImportedSheetLayer(ChangeEventArgs args)
|
||||
{
|
||||
ShowImportedSheetLayer = (bool?)args.Value == true;
|
||||
await JS.InvokeVoidAsync("lmeMap.setImportedSheetLayerVisible", ShowImportedSheetLayer);
|
||||
}
|
||||
|
||||
private async Task ToggleImportedMeasurements(ChangeEventArgs args)
|
||||
@@ -844,17 +880,6 @@
|
||||
await JS.InvokeVoidAsync("lmeMap.setDrawingMeasurementsVisible", ShowDrawingMeasurements);
|
||||
}
|
||||
|
||||
private async Task StartMeasurementDrawing(string mode)
|
||||
{
|
||||
DrawToolsVisible = false;
|
||||
await JS.InvokeVoidAsync("lmeMap.setDrawToolsVisible", false);
|
||||
ActiveTab = "map";
|
||||
LayerPanelOpen = false;
|
||||
await Task.Delay(30);
|
||||
await JS.InvokeVoidAsync("lmeMap.resize");
|
||||
await JS.InvokeVoidAsync("lmeMap.startMeasurementDrawing", mode);
|
||||
}
|
||||
|
||||
private async Task ToggleDrawTools()
|
||||
{
|
||||
DrawToolsVisible = !DrawToolsVisible;
|
||||
@@ -951,7 +976,7 @@
|
||||
try
|
||||
{
|
||||
var snapshot = await ProjectStorageService.LoadAsync(project.Id);
|
||||
await JS.InvokeVoidAsync("lmeMap.loadProjectSnapshot", snapshot, project.Name);
|
||||
ShowImportedSheetLayer = await JS.InvokeAsync<bool>("lmeMap.loadProjectSnapshot", snapshot, project.Name);
|
||||
NewProjectName = project.Name;
|
||||
IncludeCadastralParcels = project.IncludesCadastralParcels;
|
||||
ActiveTab = "map";
|
||||
|
||||
Reference in new issue
Block a user