Back to KB
Difficulty
Intermediate
Read Time
9 min

Build a Live Flight Radar in a Single HTML File

By Codcompass Team··9 min read

Client-Side Geospatial Tracking: Architecting Real-Time ADS-B Visualizations Without a Backend

Current Situation Analysis

Real-time location tracking has historically been treated as a backend-heavy problem. Engineering teams typically reach for WebSocket servers, message brokers, and stateful deployment pipelines to stream positional data to clients. This approach introduces operational overhead, increases cloud spend, and complicates the development lifecycle. For use cases that only require periodic positional updates rather than sub-second streaming, this architectural pattern is frequently over-engineered.

The misconception stems from conflating high-frequency telemetry (e.g., autonomous vehicle coordination, live multiplayer gaming) with low-frequency geospatial monitoring (e.g., fleet visibility, aviation tracking, maritime routing). ADS-B (Automatic Dependent Surveillance–Broadcast) data, for instance, updates aircraft positions every 10–30 seconds depending on the source. Polling a REST endpoint at 60-second intervals satisfies the data freshness requirement while eliminating the need for persistent connections.

AirLabs provides a free tier that returns real-time lat/lng, heading, altitude, speed, and route metadata without requiring a credit card. The free allowance caps at 1,000 requests per day. At a 60-second polling interval, a single client generates 1,440 requests daily, which exceeds the free tier. Adjusting the refresh cycle to 90 seconds yields 960 requests, keeping the implementation within free-tier limits. This constraint is rarely discussed in introductory tutorials, yet it dictates the entire refresh strategy. By treating the browser as the state manager and leveraging static hosting, developers can ship production-ready geospatial dashboards with zero infrastructure costs and minimal maintenance.

WOW Moment: Key Findings

The architectural trade-off between traditional backend-driven streaming and static client-side polling reveals a clear efficiency advantage for low-frequency tracking scenarios.

ApproachInfrastructure CostMaintenance OverheadData FreshnessScalability Limit
WebSocket + Node.js Backend$15–$40/mo (compute + egress)High (connection pooling, heartbeat logic, scaling)<1s latencyTied to server capacity & WebSocket limits
Static HTML + REST Polling$0 (CDN/edge hosting)Near-zero (no server state, no connection management)60–90s latencyTied to API provider rate limits

This finding matters because it decouples visualization from infrastructure. Developers can iterate on UI/UX, marker rendering, and data filtering without touching deployment pipelines or managing server processes. The polling model also naturally aligns with edge caching strategies, allowing regional CDNs to absorb repeated requests when the underlying dataset hasn't changed.

Core Solution

Building a client-side radar requires three coordinated systems: map initialization, telemetry ingestion, and marker lifecycle management. The implementation below uses vanilla JavaScript, Leaflet 1.9 for rendering, and CARTO's dark basemap for visual consistency. The architecture prioritizes predictable DOM updates, explicit error handling, and clean state transitions.

Architecture Decisions & Rationale

  1. Leaflet over Mapbox/Google Maps: Leaflet is lightweight, requires no API key for basic usage, and supports custom DivIcon rendering without vendor lock-in.
  2. CARTO Dark Basemap: Provides high-contrast rendering that makes colored markers stand out. Free to use with attribution.
  3. Polling over WebSockets: ADS-B data changes slowly. Polling avoids connection state management, reduces server costs, and simplifies offline fallback strategies.
  4. Marker Cleanup via Map Tracking: Using a Map keyed by aircraft hex codes prevents duplicate markers and enables O(1) lookup for updates or removals.
  5. AbortController Integration: Cancels in-flight requests if a new polling cycle begins

🎉 Mid-Year Sale — Unlock Full Article

Base plan from just $4.99/mo or $49/yr

Sign in to read the full article and unlock all 635+ tutorials.

Sign In / Register — Start Free Trial

7-day free trial · Cancel anytime · 30-day money-back