1. Overview
°Fiveo1 is a lightweight, self‑contained spatial index module that renders geotagged content records as an interactive cluster‑based visualization. It uses a client‑server architecture: a PHP backend retrieves and sanitizes data from an SQLite database, and a JavaScript frontend renders it using Leaflet and MarkerCluster.
2. Data Architecture
2.1 Backend (PHP)
· Database: SQLite3 (read‑only connection) with WAL mode and busy timeout for concurrent access.
· Query: Returns id, title, latitude, longitude, location_name, created_at, file_path, type – filtered to include only rows with non‑null coordinates.
· Media Extraction: file_path is stored as a JSON array. The first element is extracted as the direct media URL; if unavailable, the field is set to null.
· Sanitization: title and location_name are passed through htmlspecialchars to mitigate XSS.
· Serialization: The marker array is JSON‑encoded with JSON_UNESCAPED_SLASHES for clean URLs.
2.2 Frontend (JavaScript)
· Initialisation: On DOMContentLoaded, the JSON data is parsed. If empty, a placeholder message is displayed.
· Leaflet Instance: A Leaflet map is instantiated with OpenStreetMap tile layer (dark theme). The container fills the full viewport (100vh).
· Marker Clustering: Uses leaflet.markercluster to group nearby markers. Custom icons display cluster size in a dark‑themed circle. Cluster clicks zoom to bounds.
· Popup Construction:
· ° Link: If a media file exists, a degree symbol (°) is rendered as a clickable link (target="_blank") at the top‑left of the popup. It has zero margin/padding and no underline.
· Content Stack: The title (bold) follows, then location (if present), and finally the creation timestamp (formatted via toLocaleString).
· Binding: Each marker is bound to its popup with a max width of 300px.
3. Rendering Engine
· Tile Layer: Standard OSM tiles (https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png) with attribution.
· Cluster Group: Configured with maxClusterRadius: 60, spiderfyOnMaxZoom: true, zoomToBoundsOnClick: true.
· Bounds Fitting: The map automatically zooms to fit all markers with 50px padding. Fallback to [0,0] zoom level 2 if bounds are invalid.
4. Interaction Model
· Marker Click: Opens popup with content as described.
· Cluster Click: Triggers zoomToBounds on the cluster, expanding it to reveal individual markers.
· Responsiveness: window.resize event invalidates the map size to maintain correct aspect ratio.
· Close Action: A fixed close button (×) in the top‑right corner returns the user to the root path (/).
5. Security & Performance
· CSRF: Not used in this read‑only module; no POST requests are made.
· XSS: Output sanitization via htmlspecialchars on user‑supplied fields.
· Caching: No caching layer implemented; data is live‑queried on each page load (performance suitable for moderate dataset sizes).
· CDN Dependencies: External resources (Leaflet, MarkerCluster) are loaded via CDN with version pinning to ensure stability.
6. Build & Deployment
· File: map.php (placed in the web root or a subdirectory).
· Dependencies: Requires functions.php (for database connection and session handling) in the parent directory.
· Styles: Custom CSS overrides Leaflet’s default light theme with a dark aesthetic (popup backgrounds, cluster colors, attribution).
7. Conclusion
°Fiveo1 is a minimal, efficient module for visualizing geotagged content. Its data extraction, sanitization, and cluster‑based rendering provide a responsive user experience with a single‑click link to raw media, all while adhering to a dark, uncluttered design philosophy. ← All Articles← Home