From 55b1a771e26dadbc899726a65904dcfc03b3443d Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Fri, 11 Jul 2025 13:57:32 -0500 Subject: [PATCH] geolocation debug --- assets/js/map.ts | 5 +++++ lib/aprsme_web/live/map_live/index.ex | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/assets/js/map.ts b/assets/js/map.ts index 3b20e33..22ea442 100644 --- a/assets/js/map.ts +++ b/assets/js/map.ts @@ -64,6 +64,7 @@ let MapAPRSMap = { console.log("Map data attributes - center:", centerData, "zoom:", zoomData); console.log("Full element dataset:", self.el.dataset); console.log("Window location:", window.location.href); + console.log("Element HTML:", self.el.outerHTML.substring(0, 200)); if (!centerData || !zoomData) throw new Error("Missing map data attributes"); initialCenter = JSON.parse(centerData); @@ -548,6 +549,8 @@ let MapAPRSMap = { // Zoom to location self.handleEvent("zoom_to_location", (data: { lat: number; lng: number; zoom?: number }) => { + console.log("Received zoom_to_location event:", data); + if (!self.map) { console.error("Map not initialized, cannot zoom"); return; @@ -557,6 +560,8 @@ let MapAPRSMap = { const lat = parseFloat(data.lat.toString()); const lng = parseFloat(data.lng.toString()); const zoom = parseInt(data.zoom?.toString() || "12"); + + console.log("Zooming to location:", { lat, lng, zoom }); // Validate coordinates if (isNaN(lat) || isNaN(lng) || lat < -90 || lat > 90 || lng < -180 || lng > 180) { diff --git a/lib/aprsme_web/live/map_live/index.ex b/lib/aprsme_web/live/map_live/index.ex index c1fa048..f992fd3 100644 --- a/lib/aprsme_web/live/map_live/index.ex +++ b/lib/aprsme_web/live/map_live/index.ex @@ -311,7 +311,11 @@ defmodule AprsmeWeb.MapLive.Index do def handle_event("map_ready", _params, socket) do require Logger - Logger.debug("map_ready event received - current bounds: #{inspect(socket.assigns.map_bounds)}") + Logger.info( + "map_ready event received - current map_center: #{inspect(socket.assigns.map_center)}, map_zoom: #{socket.assigns.map_zoom}" + ) + + Logger.info("map_ready - default center for comparison: #{inspect(@default_center)}") # Mark map as ready and that we need to load historical packets socket = @@ -321,11 +325,16 @@ defmodule AprsmeWeb.MapLive.Index do # If we have non-default center coordinates (e.g., from geolocation), apply them now socket = - if socket.assigns.map_center == @default_center do + if socket.assigns.map_center.lat == @default_center.lat and + socket.assigns.map_center.lng == @default_center.lng do + Logger.info( + "MapLive: Map center is default (#{socket.assigns.map_center.lat}, #{socket.assigns.map_center.lng}), not applying geolocation" + ) + socket else Logger.info( - "MapLive: Applying geolocation center after map ready - center: #{inspect(socket.assigns.map_center)}, zoom: #{socket.assigns.map_zoom}" + "MapLive: Sending zoom_to_location event - center: #{inspect(socket.assigns.map_center)}, zoom: #{socket.assigns.map_zoom}" ) push_event(socket, "zoom_to_location", %{