diff --git a/assets/js/app.js b/assets/js/app.js
index f122f9c..4599b19 100644
--- a/assets/js/app.js
+++ b/assets/js/app.js
@@ -54,6 +54,8 @@ import MapAPRSMap from "./map";
import ErrorBoundary from "./hooks/error_boundary";
// Import info map hook
import { InfoMap } from "./hooks/info_map";
+// Import time ago hook
+import TimeAgoHook from "./hooks/time_ago_hook";
// Responsive Slideover Hook
let ResponsiveSlideoverHook = {
@@ -218,6 +220,7 @@ Object.keys(WeatherChartHooks).forEach(hookName => {
Hooks.ResponsiveSlideoverHook = ResponsiveSlideoverHook;
Hooks.BodyClassHook = BodyClassHook;
Hooks.ErrorBoundary = ErrorBoundary;
+Hooks.TimeAgoHook = TimeAgoHook;
// Helper function to get theme-aware colors
const getThemeColors = () => {
diff --git a/assets/js/hooks/info_map.js b/assets/js/hooks/info_map.js
index ed5d907..9fdfba9 100644
--- a/assets/js/hooks/info_map.js
+++ b/assets/js/hooks/info_map.js
@@ -1,6 +1,51 @@
// Simple map hook for displaying a single station on the info page
export const InfoMap = {
mounted() {
+ this.initializeMap();
+ },
+
+ updated() {
+ // When the element updates, check if we need to update the marker
+ const lat = parseFloat(this.el.dataset.lat);
+ const lon = parseFloat(this.el.dataset.lon);
+ const symbolHtml = this.el.dataset.symbolHtml;
+
+ // Validate coordinates
+ if (isNaN(lat) || isNaN(lon)) {
+ return;
+ }
+
+ // If map doesn't exist yet, initialize it
+ if (!this.map) {
+ this.initializeMap();
+ return;
+ }
+
+ // Update marker position if it changed
+ if (this.marker) {
+ const currentPos = this.marker.getLatLng();
+ if (currentPos.lat !== lat || currentPos.lng !== lon) {
+ // Animate the marker to the new position
+ this.marker.setLatLng([lat, lon]);
+
+ // Update the popup content
+ const callsign = this.el.dataset.callsign;
+ this.marker.setPopupContent(`${callsign}
Lat: ${lat.toFixed(6)}
Lon: ${lon.toFixed(6)}`);
+
+ // Optionally pan the map to the new position with animation
+ this.map.panTo([lat, lon], { animate: true, duration: 1 });
+ }
+
+ // Update marker icon if symbol changed
+ if (symbolHtml !== this.lastSymbolHtml) {
+ const markerIcon = this.createMarkerIcon(symbolHtml);
+ this.marker.setIcon(markerIcon);
+ this.lastSymbolHtml = symbolHtml;
+ }
+ }
+ },
+
+ initializeMap() {
// Check if Leaflet is available
if (typeof L === "undefined") {
console.error("Leaflet not loaded for InfoMap");
@@ -37,34 +82,11 @@ export const InfoMap = {
}).addTo(this.map);
// Create marker icon
- let markerIcon;
- if (symbolHtml) {
- // Use the APRS symbol if provided
- markerIcon = L.divIcon({
- html: symbolHtml,
- className: 'aprs-info-marker',
- iconSize: [32, 32],
- iconAnchor: [16, 16]
- });
- } else {
- // Default marker
- markerIcon = L.divIcon({
- html: `