dev/patrick #1
@@ -1,10 +1,11 @@
|
||||
// =====================================================================
|
||||
// WebGIS Citizen Participation Portal — Application Logic
|
||||
// Initializes the Leaflet Map, loads Contributions from the API,
|
||||
// handles the CRUD Workflow, and manages all UI Interactions.
|
||||
// Initializes Leaflet Map, loads Contributions from the API,
|
||||
// handles CRUD Workflow, and manages all UI Interactions.
|
||||
//
|
||||
// Depends on: MUNICIPALITY Object (set in index.php), Leaflet, Geoman,
|
||||
// Sidebar v2, Geocoder, PolylineMeasure, Fullscreen, SweetAlert2
|
||||
// Depends on: MUNICIPALITY Object set in Main Page, Leaflet, Geoman,
|
||||
// Sidebar, Geocoder, PolylineMeasure, Fullscreen,
|
||||
// and SweetAlert2 Plugins.
|
||||
// =====================================================================
|
||||
|
||||
|
||||
@@ -12,10 +13,10 @@
|
||||
// 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';
|
||||
|
||||
// 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') || '';
|
||||
|
||||
// Category Definitions with Labels, Icons, and Colors
|
||||
@@ -30,13 +31,13 @@ var CATEGORIES = {
|
||||
};
|
||||
|
||||
// Application State
|
||||
var map; // Leaflet Map Instance
|
||||
var sidebar; // Sidebar Instance
|
||||
var contributionsLayer; // GeoJSON Layer holding all Contributions
|
||||
var contributionsData = []; // Raw Contribution Data Array
|
||||
var activeFilters = Object.keys(CATEGORIES); // Active Category Filters (all enabled by Default)
|
||||
var drawnGeometry = null; // Temporary Storage for Geometry drawn with Geoman
|
||||
var drawnGeomType = null; // Temporary Storage for Geometry Type
|
||||
var map; // Leaflet Map Instance
|
||||
var sidebar; // Sidebar Instance
|
||||
var contributionsLayer; // GeoJSON Layer holding all Contributions
|
||||
var contributionsData = []; // Raw Contribution Data Array
|
||||
var activeFilters = Object.keys(CATEGORIES); // Active Category Filters
|
||||
var drawnGeometry = null; // Temporary Storage for Geometry drawn with Geoman
|
||||
var drawnGeomType = null; // Temporary Storage for Geometry Type
|
||||
|
||||
|
||||
// =====================================================================
|
||||
@@ -46,7 +47,8 @@ var drawnGeomType = null; // Temporary Storage for Geometry Type
|
||||
map = L.map('map', {
|
||||
center: MUNICIPALITY.center,
|
||||
zoom: MUNICIPALITY.zoom,
|
||||
zoomControl: false, // Added manually in Block 3 for Position Control
|
||||
minZoom: 10,
|
||||
zoomControl: false, // Added manually for Position Control
|
||||
attributionControl: true
|
||||
});
|
||||
|
||||
@@ -71,11 +73,6 @@ var basemapSatellite = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/
|
||||
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
|
||||
basemapCartoDB.addTo(map);
|
||||
|
||||
@@ -84,10 +81,9 @@ var basemaps = {
|
||||
'OpenStreetMap': basemapOSM,
|
||||
'CartoDB (hell)': basemapCartoDB,
|
||||
'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, {
|
||||
position: 'topright',
|
||||
@@ -99,12 +95,12 @@ var layerControl = L.control.layers(basemaps, overlays, {
|
||||
// Block 4: Map Controls
|
||||
// =====================================================================
|
||||
|
||||
// Zoom Control (top right)
|
||||
// Zoom Control
|
||||
L.control.zoom({
|
||||
position: 'topright'
|
||||
}).addTo(map);
|
||||
|
||||
// Scale Bar (bottom right)
|
||||
// Scale Bar
|
||||
L.control.scale({
|
||||
position: 'bottomright',
|
||||
maxWidth: 200,
|
||||
@@ -118,7 +114,7 @@ L.control.fullscreen({
|
||||
titleCancel: 'Vollbild beenden'
|
||||
}).addTo(map);
|
||||
|
||||
// Address Search (Geocoder with Nominatim)
|
||||
// Geocoder Address Search
|
||||
L.Control.geocoder({
|
||||
position: 'topright',
|
||||
placeholder: 'Adresse suchen...',
|
||||
@@ -126,7 +122,8 @@ L.Control.geocoder({
|
||||
geocoder: L.Control.Geocoder.nominatim({
|
||||
geocodingQueryParams: {
|
||||
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
|
||||
}
|
||||
})
|
||||
@@ -209,7 +206,7 @@ map.on('locationfound', function (e) {
|
||||
});
|
||||
|
||||
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');
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user