Last updated
Education
A straight-line look at what this browser exposes. It is not a hiking navigator, not turn-by-turn directions, and not something to trust for safety. North is shown only as the browser labels it. This page does not convert magnetic north to true north.
Why you'd want to
Two coordinates become a straight-line distance and an initial bearing. Live mode can read this device when you press Start, and a simulated walk is labeled as not your phone.
How to use it
Not started. Location and motion permission have not been requested.
Unavailable
—
No facing heading yet. Zero would be shown as 0°, not as a dash.
The trail and the waypoint stay in memory for this page only. Clear drops them. OpenStreetMap sees the map area after you show the map. Coordinates are not sent to this site.
From the browser, or unavailable
Calculated on this page
Pace and ETA appear only from a credible observed speed. Elevation appears only when both altitude accuracies are within 30 m. The turn uses the facing heading, which may not be true north.
Example vendor setup is marked below. eVar and event numbers are examples. This lab does not call Adobe.
The compass lab turns two coordinates into a distance and an initial bearing, and it can read this device's location when you start live mode. The lab does not call Adobe.
Measure the short arc
haversineMeters converts both coordinates to radians and returns meters along the great-circle arc. The formula uses the short arc across the antimeridian.
Take the initial bearing
initialBearing returns degrees clockwise from north. turnDegrees is the smallest turn from the facing heading to that bearing, from -180 to 180.
Watch the device when live mode starts
startLive calls geolocation.watchPosition and, when permission is granted, listens for deviceorientation. A point is added to the trail only when the trail is on and the step is at least one meter.
Play a scripted walk
playSimulated steps through SIMULATED_WALK and the fixed waypoint. Reduced motion shows every step at once. Pace and ETA stay null when the distance or the speed is outside the walk range. This file does not call trackLabEvent.
Distance in meters. The square root is capped so the arc stays defined.
export function haversineMeters(from: LatLng, to: LatLng) {
const dLat = toRad(to.lat - from.lat)
const dLng = toRad(to.lng - from.lng)
const lat1 = toRad(from.lat)
const lat2 = toRad(to.lat)
const h = Math.sin(dLat / 2) ** 2 + Math.cos(lat1) * Math.cos(lat2) * Math.sin(dLng / 2) ** 2
return 2 * EARTH_M * Math.asin(Math.min(1, Math.sqrt(h)))
}Initial bearing, clockwise from north.
export function initialBearing(from: LatLng, to: LatLng) {
const lat1 = toRad(from.lat)
const lat2 = toRad(to.lat)
const dLng = toRad(to.lng - from.lng)
const y = Math.sin(dLng) * Math.cos(lat2)
const x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLng)
return normalizeDegrees(toDeg(Math.atan2(y, x)))
}This lab does not queue its own event. The Google block shows an example of how you would track the interaction. Adobe is an example too.
This lab does not queue an analytics event of its own. After Accept, the site still queues virtual_page_view for the page, with page_path and page_title. Clicks inside a data-track-ignore region are not recorded. The push below is an example, not a call this page makes. This site does not call gtag('set') or Adobe.
Example only. This page does not push this object.
// Example only. This lab does not queue this event.
dataLayer.push({
event: "compass_fix_example",
source: "simulated",
})Example implementation. This site does not call Adobe. eVar57, prop57, and event57 are example variable numbers. In Launch, a data element reads the value and a rule sends it when the value changes. In the report suite, enable eVar57 with Most Recent allocation and expire it on the hit. A processing rule is unnecessary if the data element maps straight to that eVar.
Example alloy payload. _example is a placeholder schema, not a real tenant.
alloy("sendEvent", {
xdm: {
eventType: "web.webinteraction.linkClicks",
_example: {
headingSource: "simulated",
},
},
})Example hit. eVar57 is hit-scoped in this example. prop57 dies at the same hit.
s.eVar57 = "simulated"
s.prop57 = "simulated"
s.events = "event57"
s.linkTrackVars = "eVar57,prop57,events"
s.linkTrackEvents = "event57"
s.tl(true, "o", "compass_fix_example")Each lab field, the GA4 name, and the example Adobe variable. Scope is the part that usually gets lost in the translation.
Heading source
GA4. Not sent. The page labels orientation, webkit, or simulated.
Adobe. Example eVar57, expire on the hit.
Scope. Hit. A user property would keep simulated after a later live fix.
Distance
GA4. Not sent. haversineMeters returns meters between the fix and the waypoint.
Adobe. Example: do not write the meters into prop57.
Scope. A calculated value for this view. It is not an event metric.
Bearing
GA4. Not sent. initialBearing is degrees clockwise from north.
Adobe. Example prop57 on the hit.
Scope. Hit. The bearing belongs to this pair of points, not to the visit.
Coordinates
GA4. Not sent. Live mode reads them from the device. The simulated walk uses the scripted points.
Adobe. Example: do not copy latitude or longitude into eVar57.
Scope. Not an event parameter and not a user property.
Tilt a level with the phone after Start, or with the keyboard, a drag, or a labeled simulated example when the sensor is missing or denied. Nothing is stored.
Scan a QR code in this browser. The camera starts only after a click, nothing is uploaded, and the sample code only says hello. The demo still works.
The signals used to measure a visit can also change the page.