Skip to content

fix(situation): make live-GPS unit overlay toggleable in the layer control - #75

Merged
ejosterberg merged 2 commits into
openises:mainfrom
ethanhawkes-gif:fix/eoc-live-gps-layer-toggle
Aug 17, 2026
Merged

fix(situation): make live-GPS unit overlay toggleable in the layer control#75
ejosterberg merged 2 commits into
openises:mainfrom
ethanhawkes-gif:fix/eoc-live-gps-layer-toggle

Conversation

@ethanhawkes-gif

Copy link
Copy Markdown
Contributor

Fixes #74.

Problem

On situation.php the EOC map draws units through two independent layers:

  1. unitMarkers — the status-coloured roster layer, already registered in the Leaflet layer control as the Units (EOC) checkbox.
  2. UnitTracking (assets/js/unit-tracking.js) — the real-time GPS overlay. UnitTracking.init() does L.layerGroup().addTo(map) and exposes the group via getLayerGroup(), but situation.php never registered it in the layer control.

So unchecking Units (EOC) hid only the green roster markers; the live-GPS markers (coloured orange by unit.color, with the "— Last fix:" tooltip) stayed on screen with no way to hide them. Reported by @cbyrdmo on a live volunteer fire/EMS EOC deployment (#71 follow-up).

Fix

Register the tracking layer group as its own toggleable overlay — "Units — live GPS" — and register it with MapLayerPrefs so the choice persists per user, matching the other overlays. The layer stays on by default (Leaflet checks the overlay box when the layer is already on the map), so nothing changes for existing installs unless an operator toggles it. Uses the exact addOverlay + MapLayerPrefs.register patterns already used 4× in this file.

if (sitLayersControl && typeof tracker.getLayerGroup === 'function') {
    var liveGpsLayer = tracker.getLayerGroup();
    if (liveGpsLayer) {
        sitLayersControl.addOverlay(liveGpsLayer, '… Units — live GPS');
        if (window.MapLayerPrefs && window.MapLayerPrefs.register) {
            window.MapLayerPrefs.register(map, 'units_live', liveGpsLayer);
        }
    }
}

Testing

  • New tests/test_gh71_live_gps_layer_toggle.php (static source guards, matching tests/test_situation_map_fixes.php): 6/6 pass.
  • Existing tests/test_situation_map_fixes.php: 34/34 pass (no regression).
  • php -l situation.php: clean.
  • Independent adversarial review (external model): ACCEPT — no default-visibility regression, no null/throw path (both sitLayersControl and the layer are guarded, MapLayerPrefs.register is defensive), static label = no XSS, narrowly scoped.

Note: situation.php's map behavior is JS embedded in PHP; per the repo's convention these are static guards, not a headless-DOM test. I did not have a browser to visually confirm the live toggle.

Design choice (maintainer input welcome)

This keeps the two unit layers as two checkboxes (roster vs. live GPS), which is the smallest safe change and lets an operator view either independently. If you'd prefer the single Units (EOC) checkbox to govern both layers (one toggle hides all unit markers), I'm glad to revise — that variant changes live-map behavior and would want a browser check before merge.

…ntrol

The EOC map draws units through two independent layers: the status-
coloured roster layer (unitMarkers, the 'Units (EOC)' checkbox) and the
real-time GPS overlay from unit-tracking.js. UnitTracking.init() adds its
layer group straight to the map and situation.php never registered it in
the Leaflet layer control, so unchecking 'Units (EOC)' only hid the green
roster markers -- the orange live-GPS markers (coloured by unit.color)
stayed on screen with no way to turn them off.

Register the tracking group as its own toggleable overlay ('Units --
live GPS', default on so nothing changes unless the operator toggles it)
and register it with MapLayerPrefs for per-user persistence like the
other overlays. Reported by cbyrdmo on a live volunteer fire/EMS EOC
deployment (openises#71).

Adds tests/test_gh71_live_gps_layer_toggle.php (static guards, matching
tests/test_situation_map_fixes.php). New: 6/6, existing situation suite:
34/34, php -l clean.
The required "fresh install + test suite" check failed on
tests/test_ui_consistency_audit.php: the new "Units - live GPS"
overlay label used style="color:#fd7e14", which the project's
UI-consistency audit flags -- an inline hex colour can't be
overridden by a stylesheet without !important. The other four
legend dots on this page (Units (EOC), Facilities (EOC), Event
Zones, Weather Alerts) have the identical pattern and are
pre-existing, baselined debt; this one is new code, so the
audit is right to ask for better here rather than adding a fifth
exception.

Moved the colour into a new .sit-legend-live-gps CSS class in
situation.php's own <style> block and reference it via class=
instead of style=. Same visual result, passes the audit.
@ejosterberg
ejosterberg merged commit 294c14c into openises:main Aug 17, 2026
1 check passed
@ejosterberg

Copy link
Copy Markdown
Member

Thanks for the fix, and for tracking down that the orange-dots report in #73 is the same root cause -- merged.

One note on what changed after your last push: the required CI check (fresh install + test suite) initially failed on tools/ui_consistency_audit.php, which flagged the new overlay label's inline style="color:#fd7e14" as new theme-color drift (an inline hex can't be overridden by a stylesheet without !important, and this project's convention is Bootstrap-variable-or-class, not inline styles, even though four older labels on the same page already carry the same pattern as accepted debt). Rather than add a fifth exception to the baseline, I pushed a follow-up commit to this branch moving the color into a .sit-legend-live-gps CSS class. Functionally identical, and it's what got CI green.

I also closed a gap in the persistence claim while porting this into the private development tree: MapLayerPrefs.register() only actually persists a layer's on/off state across reloads if the layer id is catalogued server-side in inc/map-layer-prefs.php, and 'units_live' wasn't added there. Within a single page load the toggle worked fine either way (Leaflet's own layer control adds/removes the layer directly), but the choice would have been forgotten on every reload. Catalogued it alongside the rest for the ported version.

This is now ported into the private development tree (where releases are cut from) so it will ship in the next TicketsCAD release.

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.

situation.php: live-GPS unit overlay can't be hidden — "Units (EOC)" toggle only controls the status layer

2 participants