aprs.me/lib/aprsme_web/components/info_map_component.ex
Graham McIntire 77eb5ac05b
Fix info page map flash on packet updates
- Optimize LiveView to only update position data when coordinates actually change (>100m threshold)
- Hide loading spinner after map initialization to prevent flash on updates
- Add position change detection logic with proper nil/Decimal handling
- Add comprehensive test coverage for position change detection
- Maintain smooth map animations and existing functionality

Resolves map flashing and unnecessary reloads when new packets arrive on /info/:call pages.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-29 12:01:48 -05:00

37 lines
1.1 KiB
Elixir

defmodule AprsmeWeb.Components.InfoMapComponent do
@moduledoc """
A simple map component for showing a single station's location on the info page.
"""
use Phoenix.Component
@doc """
Renders a small map showing a single station's position.
"""
attr :id, :string, default: "info-map"
attr :lat, :float, required: true
attr :lon, :float, required: true
attr :callsign, :string, required: true
attr :symbol_html, :string, default: nil
attr :height, :string, default: "300px"
attr :zoom, :integer, default: 13
def info_map(assigns) do
~H"""
<div
id={@id}
class="info-map-container overflow-hidden h-full"
style={"height: #{@height}; min-height: 320px;"}
phx-hook="InfoMap"
data-lat={@lat}
data-lon={@lon}
data-zoom={@zoom}
data-callsign={@callsign}
data-symbol-html={@symbol_html}
>
<div id={"#{@id}-loading"} class="h-full w-full bg-base-200 flex items-center justify-center">
<span class="loading loading-spinner loading-lg"></span>
</div>
</div>
"""
end
end