A dynamic heatmap application that displays vendor locations from JSON data on an interactive Google Map.
- Interactive Heatmap: Visual representation of vendor density using Google Maps Heatmap Layer
- Individual Markers: Clickable markers for each vendor with detailed information
- Real-time Data: Fetches data from local JSON file or API endpoint
- Statistics Panel: Shows vendor count and distribution by location
- Responsive Design: Works on desktop and mobile devices
- Auto-refresh: Updates data every 5 minutes automatically
The application expects vendor data in the following format:
{
"success": true,
"message": "Vendors data fetched successfully",
"data": [
{
"id": 3,
"name": "Vendor Name",
"phone": "Phone Number",
"email": "email@example.com",
"addresses": [
{
"id": 3,
"title": "Address Title",
"address_1": "Primary Address",
"address_2": "Secondary Address",
"lat": 24.7799955,
"lng": 46.79176424
}
]
}
]
}-
Local Development:
- Place your
response.jsonfile in the same directory asindex.html - Open
index.htmlin a web browser - The application will automatically load data from the local JSON file
- Place your
-
API Integration:
- The application will fall back to the API endpoint if local file is not available
- Update the API URL in the code if needed
-
Customization:
- Modify the Google Maps API key in the script tag
- Adjust heatmap radius and opacity in the
updateMapfunction - Customize the styling in the CSS section
- Heatmap Layer: Shows vendor density with color-coded intensity
- Info Windows: Click on markers to see vendor details
- Auto-fit: Map automatically adjusts to show all vendors
- Statistics: Real-time count and location-based statistics
- Google Maps API: Uses Google Maps JavaScript API with Heatmap Layer
- Data Filtering: Automatically filters out vendors without valid coordinates
- Error Handling: Graceful fallback between local and API data sources
- Performance: Efficient marker management and heatmap rendering
- Chrome (recommended)
- Firefox
- Safari
- Edge
- Google Maps API key (included in the code)
- Web server (for local development, you can use Python's
http.serveror Node.jshttp-server) - Modern web browser with JavaScript enabled
# Using Python 3
python -m http.server 8000
# Using Node.js (if you have http-server installed)
npx http-server
# Then open http://localhost:8000 in your browserThe application supports two data sources:
- Local JSON file (
response.json) - Primary source - API endpoint - Fallback source if local file is unavailable
The application will automatically detect and use the available data source.