Two-way trail marker/list selection on geography map #83

Closed
opened 2026-05-06 21:23:48 +00:00 by spikerj · 0 comments
Owner

Summary

Add two-way binding between map cluster markers and the trail list sidebar in the geography explorer's state trail view.

Problem

Previously, clicking a trail name in the right-hand list would center the map and render the trail's GeoJSON line — but clicking a single marker on the map did nothing beyond showing a popup. There was no way to go from map → list.

Solution

CountryMapComponent

  • Added trailMarkerClicked output that emits the trailId when a single cluster marker is clicked
  • Each marker in renderClusterMarkers now has a click handler using the existing ClusterMarkerData.trailId field

StateTrailViewComponent

  • Added onMarkerClicked(trailId) handler that:
    • Selects the trail (sets selectedTrailId signal)
    • Fetches and renders the trail's geometry on the map
    • Scrolls the sidebar list to the matching trail card with smooth animation
  • Extracted shared showTrailGeometry() method used by both list-click and marker-click paths
  • Added data-trail-id attribute on each mat-card for scroll targeting via scrollIntoView()

Behavior

  • List → Map: Click card → pan map + show trail line (existing, unchanged)
  • Map → List: Click single marker → show trail line + scroll sidebar to card + highlight selection (new)
  • Click again on either side to deselect/clear (toggle behavior preserved)

Files Changed

  • country-map.component.ts — added output + marker click handler
  • state-trail-view.component.ts — added onMarkerClicked, showTrailGeometry, scrollToTrailCard
  • state-trail-view.component.html — wired (trailMarkerClicked) output + data-trail-id attribute
## Summary Add two-way binding between map cluster markers and the trail list sidebar in the geography explorer's state trail view. ## Problem Previously, clicking a trail name in the right-hand list would center the map and render the trail's GeoJSON line — but clicking a single marker on the map did nothing beyond showing a popup. There was no way to go from map → list. ## Solution ### `CountryMapComponent` - Added `trailMarkerClicked` output that emits the `trailId` when a single cluster marker is clicked - Each marker in `renderClusterMarkers` now has a click handler using the existing `ClusterMarkerData.trailId` field ### `StateTrailViewComponent` - Added `onMarkerClicked(trailId)` handler that: - Selects the trail (sets `selectedTrailId` signal) - Fetches and renders the trail's geometry on the map - Scrolls the sidebar list to the matching trail card with smooth animation - Extracted shared `showTrailGeometry()` method used by both list-click and marker-click paths - Added `data-trail-id` attribute on each `mat-card` for scroll targeting via `scrollIntoView()` ### Behavior - **List → Map**: Click card → pan map + show trail line (existing, unchanged) - **Map → List**: Click single marker → show trail line + scroll sidebar to card + highlight selection (new) - Click again on either side to deselect/clear (toggle behavior preserved) ## Files Changed - `country-map.component.ts` — added output + marker click handler - `state-trail-view.component.ts` — added `onMarkerClicked`, `showTrailGeometry`, `scrollToTrailCard` - `state-trail-view.component.html` — wired `(trailMarkerClicked)` output + `data-trail-id` attribute
Sign in to join this conversation.