geolocation debug
This commit is contained in:
parent
55b1a771e2
commit
c40e85d47a
1 changed files with 24 additions and 16 deletions
|
|
@ -547,25 +547,33 @@ defmodule AprsmeWeb.MapLive.Index do
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def handle_params(params, _url, socket) do
|
def handle_params(params, _url, socket) do
|
||||||
# Parse new map state from URL parameters
|
# Check if we should skip this update (e.g., when using IP geolocation on initial load)
|
||||||
{map_center, map_zoom} = parse_map_params(params)
|
if Map.get(socket.assigns, :should_skip_initial_url_update, false) and
|
||||||
|
not Map.get(socket.assigns, :map_ready, false) do
|
||||||
|
# Skip the URL parameter update to preserve IP geolocation
|
||||||
|
socket = assign(socket, should_skip_initial_url_update: false)
|
||||||
|
{:noreply, socket}
|
||||||
|
else
|
||||||
|
# Parse new map state from URL parameters
|
||||||
|
{map_center, map_zoom} = parse_map_params(params)
|
||||||
|
|
||||||
# Update socket state
|
# Update socket state
|
||||||
socket = assign(socket, map_center: map_center, map_zoom: map_zoom)
|
socket = assign(socket, map_center: map_center, map_zoom: map_zoom)
|
||||||
|
|
||||||
# If map is ready, update the client-side map
|
# If map is ready, update the client-side map
|
||||||
socket =
|
socket =
|
||||||
if socket.assigns.map_ready do
|
if socket.assigns.map_ready do
|
||||||
push_event(socket, "zoom_to_location", %{
|
push_event(socket, "zoom_to_location", %{
|
||||||
lat: map_center.lat,
|
lat: map_center.lat,
|
||||||
lng: map_center.lng,
|
lng: map_center.lng,
|
||||||
zoom: map_zoom
|
zoom: map_zoom
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
socket
|
socket
|
||||||
end
|
end
|
||||||
|
|
||||||
{:noreply, socket}
|
{:noreply, socket}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue