Skip to content

Title: Fix vehicle markers not updating on realtime data change#12

Open
kudlav wants to merge 1 commit intoTriLinder:mainfrom
kudlav:fix-data-update
Open

Title: Fix vehicle markers not updating on realtime data change#12
kudlav wants to merge 1 commit intoTriLinder:mainfrom
kudlav:fix-data-update

Conversation

@kudlav
Copy link

@kudlav kudlav commented Feb 5, 2026

This PR fixes a bug where vehicle markers remained static on the map even when the underlying realtimeGtfsDataStore updated (every 10s). Previously, markers would only update their positions if the user manually panned or zoomed the map.

The issue was caused by a race condition in the manual store subscription inside onMount:

realtimeGtfsDataStore.subscribe(function(value) { updateMarkers() });

This listener was firing before Svelte had propagated the new store value to the component's local $realtimeGtfsDataStore. Since updateMarkers() relies on $realtimeGtfsDataStore to draw vehicles, it was executing with stale data during the automatic fetch cycle.

I replaced the manual .subscribe() in onMount with a native Svelte reactive statement:

$: if (map && $realtimeGtfsDataStore) {
    updateMarkers();
}

This guarantees that updateMarkers() runs only after the $realtimeGtfsDataStore variable has been updated with fresh data.

Acceptance

  • Firefox on Windows 11
  • Android 16 on Google Pixel 8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant