An open-source alternative to Google Maps API built with modern web technologies and free mapping services.
This application provides a complete mapping solution using entirely open-source and free services, eliminating the need for costly Google Maps API subscriptions. Perfect for developers looking for a cost-effective mapping solution with full control over their implementation.
- Interactive Maps - Powered by OpenStreetMap (OSM) and Leaflet.js
- Routing & Navigation - Turn-by-turn directions using OSRM (Open Source Routing Machine)
- Geocoding & Search - Location search and reverse geocoding via Nominatim API
- Real-time Updates - WebSocket support for live location tracking and updates
- Zero API Costs - Completely free and open-source infrastructure
- Leaflet.js - Interactive map rendering and manipulation
- JavaScript (98.4%)
- HTML (1.5%)
- CSS (0.1%)
- Node.js/Express - Server-side logic and API handling
- WebSocket - Real-time bidirectional communication
- OpenStreetMap (OSM) - Map tiles and geographic data
- OSRM - Routing engine for navigation
- Nominatim - Geocoding and address lookup
map-app/
βββ backend/ # Server-side application
β βββ routes/ # API endpoints
β βββ controllers/ # Business logic
β βββ websocket/ # WebSocket handlers
βββ frontend/ # Client-side application
β βββ js/ # JavaScript modules
β βββ css/ # Stylesheets
β βββ index.html # Main HTML file
βββ package.json
βββ README.md
- Node.js (v14 or higher)
- npm or yarn
- Clone the repository
git clone https://github.com/Prateet-Github/map-app.git
cd map-app- Install dependencies
npm install- Start the backend server
cd backend
npm start- Start the frontend development server
cd frontend
npm start- Open your browser and navigate to
http://localhost:5173
// Initialize map
const map = L.map('map').setView([latitude, longitude], zoomLevel);
// Add OSM tile layer
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: 'Β© OpenStreetMap contributors'
}).addTo(map);// Search for a location
fetch(`https://nominatim.openstreetmap.org/search?q=${query}&format=json`)
.then(response => response.json())
.then(data => {
// Handle location results
});// Get route between two points
fetch(`https://router.project-osrm.org/route/v1/driving/${lon1},${lat1};${lon2},${lat2}?overview=full&geometries=geojson`)
.then(response => response.json())
.then(data => {
// Display route on map
});// Connect to WebSocket server
const socket = new WebSocket('ws://localhost:5001');
socket.onmessage = (event) => {
// Handle real-time location updates
};| Method | Endpoint | Description |
|---|---|---|
| GET | /api/geocode |
Search for locations |
| GET | /api/reverse |
Reverse geocoding |
| POST | /api/route |
Calculate route between points |
| GET | /api/places |
Find nearby places |
- Pan and zoom controls
- Custom markers and popups
- Layer management
- Geolocation support
- Address search
- Reverse geocoding
- Autocomplete suggestions
- Place details
- Multi-point routing
- Alternative routes
- Distance and duration calculation
- Turn-by-turn directions
- Live location tracking
- Real-time marker updates
- Multi-user collaboration
- Event broadcasting
| Feature | This App | Google Maps API |
|---|---|---|
| Cost | Free | Paid (after quota) |
| Rate Limits | Generous | Restrictive |
| Data Access | Full control | Limited |
| Customization | Complete | Limited |
| Privacy | Self-hosted | Google servers |
| Open Source | Yes | No |
Create a .env file in the backend directory:
PORT=5001
FRONTEND_URL=http://localhost:5173
WEBSOCKET_PORT=5001Customize map settings in frontend/js/config.js:
const MAP_CONFIG = {
defaultCenter: [51.505, -0.09],
defaultZoom: 13,
maxZoom: 19,
minZoom: 3
};Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is open source and available under the MIT License.
- OpenStreetMap - Map data and tiles
- OSRM Project - Routing engine
- Nominatim - Geocoding service
- Leaflet.js - Mapping library
For issues, questions, or contributions, please open an issue on GitHub.
Built with β€οΈ using open-source technologies