Vishal Tyagi
← Projects
Web·shipped

Real-time Location Tracker

Browser GPS sharing over Socket.IO: every connected client broadcasts coordinates; a shared Leaflet map shows live markers with device popups and auto-fit bounds.

Date2024-07
Reading TimeN/A
Statusshipped
StackNode.js, Socket.IO, Leaflet.js

What it does

Open the page on two phones. Allow location. Both markers show up on one map, move as you walk, and disappear when a tab closes. The server is a thin relay — no database, no sessions beyond socket.id, and no auth: anyone with the page URL sees every connected client’s live location. Fine for a demo on a private link; a real deploy needs access control first.

Pair with the step-by-step Socket.IO + Leaflet codelab if you want to rebuild it.

Architecture

socket.on('sendLocation', (coords) => {
  io.emit('receiveLocation', { id: socket.id, deviceInfo, ...coords });
});

socket.on('disconnect', () => {
  io.emit('userDisconnect', socket.id);
});

Clients own markers keyed by socket.id. Disconnect removes the marker everywhere. fitBounds keeps everyone visible until the user pans manually.

What it demonstrates

  • WebSocket broadcast as a message bus
  • Browser Geolocation + Leaflet without a mapping SaaS
  • Keeping server state near zero when the client can hold the UI model