Three zones — a Polygon, a Circle and a
Corridor — each wrapped in a Geofence watching a simulated
truck. The fence fires enter and exit as the truck crosses
each boundary, and dwell once it has stayed inside for 5 seconds. A
30 m hysteresis keeps GPS jitter on the fence line from firing bursts of
events, which is what makes this usable with real trackers.
Geofence takes any zone exposing
contains(latlng) and distanceToEdge(latlng) —
Polygon (holes respected), Circle, Corridor —
or a raw latlngs array. Zone layers are read live: edit the polygon and the fence
follows.
hysteresis: 30 means a position must be 30 m past the boundary
before the state flips. Watch the truck skim a zone edge: no enter/exit chatter.
dwell: 5000 fires once per stay — the difference between "drove past
the yard" and "arrived at the yard".
Tracker: each simulated ping glides the
marker instead of teleporting it, and the fences evaluate every animation frame via
the marker's ordinary move events.
Corridor is a polyline with a width in meters — its stroke is
recomputed per zoom so it always spans 260 real meters. Zoom in and out to check.