Real-Time Map

A live location tracking app that shows multiple users' positions on an interactive map in real-time using WebSockets.

Real-Time Map - Image 1

About This Project

Real-Time Map is a Node.js web application that tracks and displays multiple users' live locations on an interactive map simultaneously. When a user opens the app, their browser shares geolocation data which is emitted to the server via Socket.io. The server broadcasts all connected users' coordinates to every client in real-time, updating their pins on the map instantly. Built with Express.js and EJS for server-side rendering, with Socket.io handling the bi-directional WebSocket communication.

Key Features

  • Live multi-user location tracking — all connected users appear as pins on the map
  • Real-time coordinate broadcasting via Socket.io WebSockets
  • Browser Geolocation API integration for automatic location detection
  • Instant map updates when users join, move, or disconnect
  • Server-side rendered views with EJS templating
  • Deployed and publicly accessible on Render

Challenges & Solutions

1

Managing multiple concurrent Socket.io connections and broadcasting efficiently

Maintained an in-memory Map keyed by socket ID on the server to store each user's latest coordinates; on every location update the server broadcast the entire active users map to all clients, avoiding individual targeted emits

2

Handling user disconnect events to cleanly remove their pin from other clients' maps

Listened to Socket.io's built-in 'disconnect' event to immediately delete the departing user's entry from the server map and emit a 'user-left' event carrying their socket ID, so every connected client could remove that pin from their Leaflet map instance

Technologies Used

Node.jsExpress.jsSocket.ioEJSJavaScriptCSSLeaflet.js / Google Maps API

Project Details

Category:Real-Time Web Application
Year:2024

Tags

WebSocketsSocket.ioReal-timeMapsLocation TrackingNode.js