geolocation debug
This commit is contained in:
parent
96e4c305f0
commit
55b1a771e2
2 changed files with 17 additions and 3 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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", %{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue