map update on any focus change #111
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
gtfs.zone/coloring-book#111
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Currently the map only updates for route and stop page navigations. Three page types — home, service, and timetable — do not trigger any map update, and the agency page wires to a no-op. This means navigating via breadcrumbs or clicking services/timetables leaves the map frozen at whatever was last focused. The fix is to add a
focusFeed()method toMapController(clear highlights + fit all stops), wire it for home and service pages, callhighlightRoute(route_id)for timetable pages, and fix the agency implementation which already has ahighlightAgencyRoutes()method that was never connected.Key tradeoff:
highlightAgencyRoutes()inMapController(line 724) has a loop bug — it callsthis.highlightRoute()per agency route, and each call invokesclearHighlights()first, so only the last route ends up highlighted. This needs to be fixed as part of wiring agency support.Relevant Context
src/modules/page-content-renderer.ts:219—renderPage()switchsrc/modules/page-content-renderer.ts:278—renderHome()src/modules/page-content-renderer.ts:481—renderAgency()callsfocusOnAgency()src/modules/page-content-renderer.ts:492—renderRoute()callshighlightRoute()src/modules/page-content-renderer.ts:636—renderTimetable()src/modules/page-content-renderer.ts:668—renderService()src/modules/page-content-renderer.ts:103–115src/modules/map-controller.ts:474–611fitMapToData()(private)src/modules/map-controller.ts:430highlightAgencyRoutes()(buggy loop)src/modules/map-controller.ts:724src/modules/browse-navigation.ts:535—highlightAgencyOnMap()src/modules/browse-navigation.ts:317–326Phase 1: Add
focusFeed()to MapController and wire home/service pagesGoal: when the user lands on the home or service page (by navigation or breadcrumb), the map should clear any current highlight and fit bounds to show all GTFS data — the "feed view".
src/modules/map-controller.ts, makefitMapToData()public (rename or add a thin public wrapperfocusFeed()):focusFeed: () => voidto themapControllerinterface insrc/modules/page-content-renderer.ts(near line 110).renderHome()(page-content-renderer.ts:278), add as the first line:renderService()(page-content-renderer.ts:668), add before the return:focusFeed: () => voidto the mapController adapter insrc/modules/browse-navigation.ts(near line 317):Notes: Also had to add
focusFeedto the privatemapControllerfield type (line 61) and the constructor parameter type (line 199) inbrowse-navigation.ts— both inline structural types needed updating to match the new public method.Gotcha:
fitMapToData()is a no-op if no stops are loaded (guard is already in place). This is fine — if the feed is empty, no map movement is expected.Phase 2: Wire timetable pages to highlight the route
Goal: navigating to a timetable page (route + service combination) should highlight and fly to the route, same as the route page.
renderTimetable()(page-content-renderer.ts:636), add before the return: (highlightRouteis already in the interface — no interface change needed.)Gotcha:
highlightRouteis already defined in the mapController dependency interface. No new wiring needed in browse-navigation.Phase 3: Fix agency map focus
Goal: navigating to an agency page should highlight all routes for that agency and fit the map to them.
Step A — fix the
highlightAgencyRoutesloop bug insrc/modules/map-controller.ts:724:The current loop calls
this.highlightRoute()per route, and each invocation callsclearHighlights()first, so only the last route is ever highlighted. Replace with a direct call torouteRenderer?.highlightRoutes()(plural):highlightAgencyRoutes()to:this.clearHighlights()once.route_ids for the agency.this.routeRenderer?.highlightRoutes(agencyRouteIds)(plural — already used inhighlightStop).this.fitToRoutes(agencyRouteIds).Step B — connect the no-op in
src/modules/browse-navigation.ts:535:highlightAgencyOnMap()from a no-op to:Gotcha:
highlightAgencyRoutesguards onagencyRoutes.length === 0and returns early — safe to call with any agency_id.fitToRoutesalso guards oncoordinates.length > 0.Original Issue