dev/patrick #1

Merged
lukas.uptmoor merged 69 commits from dev/patrick into main 2026-04-20 16:32:31 +02:00
Showing only changes of commit 1714e33fa7 - Show all commits

View File

@@ -1,10 +1,11 @@
// ===================================================================== // =====================================================================
// WebGIS Citizen Participation Portal — Application Logic // WebGIS Citizen Participation Portal — Application Logic
// Initializes the Leaflet Map, loads Contributions from the API, // Initializes Leaflet Map, loads Contributions from the API,
// handles the CRUD Workflow, and manages all UI Interactions. // handles CRUD Workflow, and manages all UI Interactions.
// //
// Depends on: MUNICIPALITY Object (set in index.php), Leaflet, Geoman, // Depends on: MUNICIPALITY Object set in Main Page, Leaflet, Geoman,
// Sidebar v2, Geocoder, PolylineMeasure, Fullscreen, SweetAlert2 // Sidebar, Geocoder, PolylineMeasure, Fullscreen,
// and SweetAlert2 Plugins.
// ===================================================================== // =====================================================================
@@ -12,10 +13,10 @@
// Block 1: Configuration and Application State // Block 1: Configuration and Application State
// ===================================================================== // =====================================================================
// API Endpoint relative Path from public/ to api/ // API Endpoint as relative Path
var API_URL = '../api/contributions.php'; var API_URL = '../api/contributions.php';
// Current User Name set via Login Modal, stored in sessionStorage // Current User Name, set via Login Modal, stored in sessionStorage
var currentUser = sessionStorage.getItem('webgis_user') || ''; var currentUser = sessionStorage.getItem('webgis_user') || '';
// Category Definitions with Labels, Icons, and Colors // Category Definitions with Labels, Icons, and Colors
@@ -34,7 +35,7 @@ var map; // Leaflet Map Instance
var sidebar; // Sidebar Instance var sidebar; // Sidebar Instance
var contributionsLayer; // GeoJSON Layer holding all Contributions var contributionsLayer; // GeoJSON Layer holding all Contributions
var contributionsData = []; // Raw Contribution Data Array var contributionsData = []; // Raw Contribution Data Array
var activeFilters = Object.keys(CATEGORIES); // Active Category Filters (all enabled by Default) var activeFilters = Object.keys(CATEGORIES); // Active Category Filters
var drawnGeometry = null; // Temporary Storage for Geometry drawn with Geoman var drawnGeometry = null; // Temporary Storage for Geometry drawn with Geoman
var drawnGeomType = null; // Temporary Storage for Geometry Type var drawnGeomType = null; // Temporary Storage for Geometry Type
@@ -46,7 +47,8 @@ var drawnGeomType = null; // Temporary Storage for Geometry Type
map = L.map('map', { map = L.map('map', {
center: MUNICIPALITY.center, center: MUNICIPALITY.center,
zoom: MUNICIPALITY.zoom, zoom: MUNICIPALITY.zoom,
zoomControl: false, // Added manually in Block 3 for Position Control minZoom: 10,
zoomControl: false, // Added manually for Position Control
attributionControl: true attributionControl: true
}); });
@@ -71,11 +73,6 @@ var basemapSatellite = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/
maxZoom: 20 maxZoom: 20
}); });
var basemapTopo = L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://opentopomap.org">OpenTopoMap</a>',
maxZoom: 18
});
// Set Default Basemap // Set Default Basemap
basemapCartoDB.addTo(map); basemapCartoDB.addTo(map);
@@ -84,10 +81,9 @@ var basemaps = {
'OpenStreetMap': basemapOSM, 'OpenStreetMap': basemapOSM,
'CartoDB (hell)': basemapCartoDB, 'CartoDB (hell)': basemapCartoDB,
'Satellit (Esri)': basemapSatellite, 'Satellit (Esri)': basemapSatellite,
'Topographisch': basemapTopo
}; };
var overlays = {}; // Populated later with Contribution Layer var overlays = {}; // Populated later with Contribution Layers
var layerControl = L.control.layers(basemaps, overlays, { var layerControl = L.control.layers(basemaps, overlays, {
position: 'topright', position: 'topright',
@@ -99,12 +95,12 @@ var layerControl = L.control.layers(basemaps, overlays, {
// Block 4: Map Controls // Block 4: Map Controls
// ===================================================================== // =====================================================================
// Zoom Control (top right) // Zoom Control
L.control.zoom({ L.control.zoom({
position: 'topright' position: 'topright'
}).addTo(map); }).addTo(map);
// Scale Bar (bottom right) // Scale Bar
L.control.scale({ L.control.scale({
position: 'bottomright', position: 'bottomright',
maxWidth: 200, maxWidth: 200,
@@ -118,7 +114,7 @@ L.control.fullscreen({
titleCancel: 'Vollbild beenden' titleCancel: 'Vollbild beenden'
}).addTo(map); }).addTo(map);
// Address Search (Geocoder with Nominatim) // Geocoder Address Search
L.Control.geocoder({ L.Control.geocoder({
position: 'topright', position: 'topright',
placeholder: 'Adresse suchen...', placeholder: 'Adresse suchen...',
@@ -126,7 +122,8 @@ L.Control.geocoder({
geocoder: L.Control.Geocoder.nominatim({ geocoder: L.Control.Geocoder.nominatim({
geocodingQueryParams: { geocodingQueryParams: {
countrycodes: 'de', countrycodes: 'de',
viewbox: '8.0,52.5,8.5,52.8', viewbox: (MUNICIPALITY.center[1] - 0.3) + ',' + (MUNICIPALITY.center[0] - 0.2) + ',' +
(MUNICIPALITY.center[1] + 0.3) + ',' + (MUNICIPALITY.center[0] + 0.2),
bounded: 1 bounded: 1
} }
}) })
@@ -209,7 +206,7 @@ map.on('locationfound', function (e) {
}); });
map.on('locationerror', function () { map.on('locationerror', function () {
Swal.fire('Standort nicht gefunden', 'Bitte erlauben Sie den Standortzugriff in Ihrem Browser.', 'warning'); Swal.fire('Standort nicht gefunden', 'Bitte gestatten Sie den Standortzugriff in Ihrem Browser.', 'warning');
}); });