Skip to content

Real-time fleet tracking and geofencing system using Firebase, MySQL, Google Maps, and PHP. Supports GPS data from IoT devices or smartphones.

License

Notifications You must be signed in to change notification settings

Afif718/smart-gps-fleet-tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Fleet Geofence Tracker

🌍 Overview

This is a real-time fleet tracking and geofencing system built with PHP, Firebase, MySQL, and Google Maps. The system allows administrators to monitor hundreds of trucks simultaneously, view truck details, draw and manage geofences, and log vehicle entries into those geofenced zones.

πŸ“¦ Features

  • πŸ”΄ Live Tracking: Real-time truck locations updated automatically on Google Maps
  • πŸ“Œ Geofence Drawing Tool: Draw circular or polygonal geofences using a simple UI
  • 🧭 Geofence Entry Logging: Automatically logs when a vehicle enters a geofence, with timestamp, geofence name, and truck ID
  • πŸ“‹ Truck Info Dashboard: Lists all registered trucks with their latest GPS and status info
  • πŸ“ Geofence Viewer: View all saved geofences on a map
  • πŸ”„ Data Sources: Supports GPS data collection from IoT devices or smartphone apps
  • πŸ’Ύ Database: Uses Firebase for real-time updates and MySQL for persistent logging

πŸ“ File Structure

.
β”œβ”€β”€ firebaseRDB.php                            # Firebase Realtime Database PHP handler
β”œβ”€β”€ index.php                                  # Dashboard showing all trucks with live data
β”œβ”€β”€ live_location_of_trucks.php                # Live location map view for individual truck
β”œβ”€β”€ map_form.php                               # Draw and save new geofences
β”œβ”€β”€ showPoly.php                               # View all existing geofences on map
β”œβ”€β”€ vehicles_geofence_log.php                  # Logs of vehicle entries into geofenced areas

πŸ”§ Tech Stack

  • Frontend: HTML, CSS, Bootstrap, JavaScript, Google Maps API
  • Backend: PHP
  • Database:
    • Firebase Realtime DB (for live data)
    • MySQL (for logs and storing data)
  • Other: AJAX, jQuery, Cron Jobs (optional for syncing)

πŸ”„ GPS Data Collection

Supports two modes:

  1. IoT GPS Devices sending live GPS data
  2. Smartphones with location tracking apps running in the background

βž• Data is stored into:

  • Firebase: For real-time syncing and monitoring
  • MySQL: For long-term historical analysis and reporting

πŸ—€οΈ Industry Applications

This system can benefit various industries and sectors, including:

  • β›½ Logistics & Transportation – For managing and monitoring fleets, deliveries, and shipments
  • ✈️ Aviation Ground Services – To track movement of service vehicles within airport premises
  • ⛴️ Mining & Construction – To monitor on-site equipment and ensure safety within predefined zones
  • 🌳 Forestry & Agriculture – For managing movement of equipment or transport trucks in large, remote areas
  • πŸ›οΈ Municipal & Utility Services – For tracking garbage collection, maintenance vehicles, or emergency services
  • πŸš‘ Healthcare (Ambulance Fleet) – To track ambulances in real-time and log hospital zone entries
  • 🚨 Security & Law Enforcement – Monitor patrol routes and enforce zone-specific movement
  • 🏒 Real Estate & Facility Management – Manage on-site vehicle access for residential or industrial complexes

πŸ—ΊοΈ How it Works

  1. Drivers or IoT devices send GPS coordinates to Firebase
  2. index.php fetches live data from Firebase and displays all trucks
  3. Admins draw geofences using map_form.php and save them to the DB
  4. showPoly.php renders all saved geofences on a map
  5. track.php shows each truck's live location on a separate map
  6. When a truck enters a geofence, vehicles.php logs it with:
    • πŸ“Œ Truck name, registration ID
    • 🧭 Geofence name
    • πŸ“… Date & Time

πŸš€ Setup Instructions

  1. Clone this repository:
git clone https://github.com/your-username/fleet-geofence-tracker.git
cd fleet-geofence-tracker
  1. Add your Firebase URL to firebaseRDB.php:
$firebase = new firebaseRDB("https://your-project.firebaseio.com/");
  1. Configure your Google Maps API key in relevant files (e.g., live_location_of_trucks.php, map_form.php)

  2. Deploy on your local server or live server with PHP 7+


πŸ“Έ Screenshots

image

image

image

image

image

image

image

image


πŸ“œ License

This project is licensed under the MIT License.


πŸ‘¨β€πŸ’» Author

M. H. A. Afif
Founder & Lead Engineer – SystemSage Solutions
πŸ”— LinkedIn
πŸ”— Portfolio Website


β€œReal-time fleet intelligence for smarter, safer, and more sustainable logistics.”

About

Real-time fleet tracking and geofencing system using Firebase, MySQL, Google Maps, and PHP. Supports GPS data from IoT devices or smartphones.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published