Skip to content

Repository files navigation

Tracker — GPS Activity Tracker

Live app:psiborg.github.io/Tracker
Repository:github.com/psiborg/Tracker

A Progressive Web App (PWA) for recording hiking and outdoor activities with real-time GPS tracking, route visualization, and activity history. Works fully offline after the first load and can be installed to the home screen on iOS and Android.


Features

  • Real-time GPS tracking — live crosshair marker follows every position fix; accuracy circle shows GPS precision
  • Smooth route line — track path drawn using an Exponential Moving Average (EMA) filter to reduce GPS jitter; can be disabled in Settings
  • 2 base map layers — OpenStreetMap and OpenTopoMap
  • Overlay layers — Waymarked Hiking Trails, Cycling Routes, and a per-activity path layer added automatically after each save
  • Offline Maps — bulk-download tiles for a named area before heading out; manage saved areas with rename, zoom-to, and delete
  • Compass rose — top-left map control showing live bearing in degrees and 16-point direction (e.g. 275° WNW), fed by Device Orientation API when stationary
  • Re-center button — appears when the map is panned away from the current GPS location; taps back to live following
  • 10-field info dashboard — Date, Time, Latitude, Longitude, Speed, Accuracy, Distance, Altitude, Heading, Map Zoom
  • Start / Pause / Stop — Start and Pause share a single toggle button; a blinking REC indicator sits above the map scale bar
  • Activity history — saved activities listed with name, date, distance, and duration; tap to view all data points; delete with the ✕ icon
  • Saved path overlays — each activity's route is registered as a named overlay layer and persists across sessions
  • Settings — smooth lines toggle, jitter filter slider, record interval, GPS poll rate, and accuracy filter; all persisted to localStorage
  • Light / Dark theme — toggle from the hamburger menu; defaults to dark
  • About dialog — shows app version, active service worker cache name, and a link to the GitHub repository
  • Fully offline — all library and font assets are bundled locally; map tiles are cached by the service worker as they are viewed
  • PWA installable — add to home screen on iOS Safari and Android Chrome for a full-screen native experience

Project Structure

tracker/
├── index.html # App shell — structure only, no inline CSS or JS
├── app.css # All application styles and CSS custom properties
├── app.js # All application logic (IIFE, strict mode)
├── manifest.json # PWA manifest (name, icons, display mode)
├── sw.js # Service worker — precaches assets, caches map tiles
├── README.md
│
├── lib/ # Bundled third-party libraries (no CDN dependency)
│ ├── leaflet.min.css # Leaflet 1.9.4 styles
│ ├── leaflet.min.js # Leaflet 1.9.4 library
│ ├── fonts.css # @font-face declarations pointing to local woff2 files
│ └── images/ # Leaflet marker and layer-switcher sprites
│ ├── layers.png
│ ├── layers-2x.png
│ ├── marker-icon.png
│ ├── marker-icon-2x.png
│ └── marker-shadow.png
│
└── fonts/ # Bundled web fonts (no Google Fonts CDN dependency)
├── rajdhani-latin-400-normal.woff2
├── rajdhani-latin-500-normal.woff2
├── rajdhani-latin-600-normal.woff2
├── rajdhani-latin-700-normal.woff2
└── share-tech-mono-latin-400-normal.woff2

Deployment

The app requires only a static HTTPS file server — no build step, no back-end.

Option A — GitHub Pages

git init
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/psiborg/Tracker.git
git push -u origin main

Enable Pages under Settings → Pages → Source: main branch / root.

Option B — Netlify / Vercel

Drag and drop the tracker/ folder into the Netlify or Vercel dashboard. Both serve over HTTPS automatically.

Option C — Local development server

# Python (built into macOS and Linux)
python3 -m http.server 8080
# then open http://localhost:8080

HTTPS is required in production. The Geolocation API and Service Worker are blocked on plain HTTP. localhost is the only exception and is suitable for development.

Forcing a cache refresh (iOS Safari)

After deploying updated files, bump the CACHE_NAME constant in sw.js (e.g. tracker-v3tracker-v4). The service worker's activate handler automatically deletes the old cache. On device, open the URL in Safari, pull to refresh once, close the tab fully, then reopen it.

Alternatively, clear site data manually: Settings → Safari → Advanced → Website Data → search your domain → swipe to delete.


Installing to Home Screen

iOS (Safari)

  1. Open the app URL in Safari
  2. Tap the Share button (box with arrow)
  3. Tap Add to Home Screen
  4. Confirm the name and tap Add

Android (Chrome)

  1. Open the app URL in Chrome
  2. Tap the menu → Add to Home screen, or tap the Install prompt in the address bar
  3. Tap Install

Usage

Toolbar

ButtonStateAction
StartIdleBegins recording; button becomes Pause
PauseRecordingSuspends recording; button reverts to Start (resume)
StartPausedResumes recording; button becomes Pause again
StopRecording or pausedEnds the activity; prompts for a name before saving
HistoryAnyOpens the activity history modal

Map Controls

ControlLocationPurpose
Layer switcherTop-rightSwitch base map; toggle trail and activity overlays
Compass roseTop-leftLive bearing; rotates needle to current heading
Re-center buttonBottom-centerReturns map to current GPS location and resumes following
Zoom +/−Bottom-rightZoom in and out
Scale barBottom-leftMap scale reference

Menu (☰)

ItemAction
Switch ThemeToggle between Light and Dark mode
SettingsOpen the recording settings dialog
Download AreaOpen the Offline Maps dialog to cache tiles for offline use
AboutShow version, cache name, and GitHub link

Info Dashboard Reference

FieldDescription
DateCurrent date yyyy/mm/dd
TimeCurrent time hh:mm:ss (live clock)
LatitudeGPS latitude, 6 decimal places
LongitudeGPS longitude, 6 decimal places
SpeedGround speed in km/h (GPS, only while moving)
AccuracyGPS horizontal accuracy in metres
DistanceTotal distance recorded in the current session (km)
AltitudeGPS altitude in metres above sea level (hardware dependent)
HeadingBearing in degrees and 8-point cardinal label; falls back to device compass when stationary
Map ZoomCurrent Leaflet map zoom level

Settings Reference

Recording

SettingDefaultDescription
Smooth Route LinesOnApply EMA filter to the drawn path to reduce GPS jitter
Jitter Filter3 mMinimum movement before a point is recorded; 0 = record all

Data Points

SettingDefaultDescription
Record Interval5 sHow often a point is saved to the activity; lower = more detail and more storage
GPS Poll Rate1 sHow frequently the GPS hardware is queried for a new position
Accuracy Filter50 mDiscard points with GPS accuracy worse than this value

Settings are persisted to localStorage under the key tracker_settings and restored on every launch.


Map Layers

Base Maps

LayerSourceMax Zoom
🗺 OpenStreetMapopenstreetmap.org19
🏔 OpenTopoMapopentopomap.org17

Built-in Overlays

LayerSource
🥾 Hiking Trailswaymarkedtrails.org
🚴 Cycling Routeswaymarkedtrails.org

Activity Overlays

Each saved activity with at least 2 recorded points is automatically registered as a named overlay layer (📍 Activity Name) in the layer switcher. Layers are colour-coded and persist across sessions. Deleting an activity from History removes its overlay layer.


Offline Maps

The Offline Maps dialog (☰ → Download Area) lets you pre-cache map tiles for a specific geographic area so the app works without an internet connection.

Download tab

  1. Enter a name for the area (e.g. Bruce Trail North)
  2. Select which map layers to cache (OpenStreetMap and/or OpenTopoMap)
  3. Set the zoom range — Min Zoom (overview, default 10) and Max Zoom (detail, default 16)
  4. The live estimate shows the approximate tile count and storage size; downloads above 3,000 tiles are blocked with a prompt to zoom in or narrow the range
  5. Tap Download — a progress bar tracks the fetch; tap Stop to cancel mid-download (already-fetched tiles remain cached)
  6. On completion the modal switches automatically to the Saved Areas tab

Tile count reference

ZoomCoverage per tileTypical use
10~78 km²Regional overview
12~5 km²Town / park level
14~1.2 km²Trail network
16~0.3 km²Full street / path detail

A typical 10 km hiking route cached at zooms 10–16 on both layers is roughly 300–600 tiles (~5–9 MB).

Saved Areas tab

Each completed download is saved as a named area record. For each area you can:

ActionDescription
RenameTap the pencil icon; edit inline; confirm with Enter or blur
🔍 Zoom toFrames the downloaded bounding box on the map and closes the dialog
🗑 DeleteRemoves the area record; cached tiles are retained in the service worker cache (they may overlap with other areas)

Area metadata is stored under the localStorage key tracker_dl_areas. Cached tiles live in the service worker's tracker-tiles cache and are served automatically when offline.


Data Storage

Activity data is stored in localStorage under the key tracker_activities. Points are saved in a compact format to minimise storage usage.

Compact point format

KeyFieldNotes
aLatitude5 decimal places (~1 m accuracy)
oLongitude5 decimal places
tTimestampUnix ms
lAltitudeInteger metres; omitted if null
cAccuracy1 decimal place metres; omitted if null
sSpeedkm/h, 1 decimal place; omitted if null
hHeadingInteger degrees; omitted if null

Storage estimate

Record intervalPoints/hourPer activity60 activities
1 s3,600~137 KB~8 MB
5 s (default)720~27 KB~1.6 MB
10 s360~14 KB~0.8 MB

localStorage is capped at 5–10 MB depending on the browser. At the default 5 s interval, ~180 one-hour activities fit comfortably within a 5 MB budget.

Storage keys

KeyContents
tracker_activitiesJSON array of all saved activity records
tracker_settingsJSON object of user settings
tracker_dl_areasJSON array of downloaded area metadata records

Dependencies

All dependencies are bundled locally. No internet connection is required after the first page load.

DependencyVersionLicenseLocation
Leaflet1.9.4BSD-2-Clauselib/
Rajdhani (font)OFL-1.1fonts/
Share Tech Mono (font)OFL-1.1fonts/

Map tile data is provided by third-party services subject to their own terms:


Browser Compatibility

BrowserVersionNotes
Safari (iOS)16.4+Full PWA install support; Device Orientation requires user permission
Chrome (Android)90+Full PWA install support
Chrome (Desktop)90+GPS via IP geolocation; mock GPS available on file://
Firefox90+PWA install not supported; app functions normally
Edge90+Full PWA install support

License

MIT — see LICENSE for details.

About

A progressive web app for recording hiking and outdoor activities with real-time GPS tracking, route visualization, and activity history.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages