AI News Hub Logo

AI News Hub

Build a Real-Time Australian Emergency Map with JavaScript (Free API)

DEV Community
Jack Dempsey

I built a free API that aggregates real-time emergency data from all 8 Australian states. In this tutorial, I'll show you how to build a live emergency map using Leaflet.js and the EmergencyAPI. A browser-based map showing active bushfires, floods, storms, and other emergencies across Australia. Colour-coded by event type, updating in real-time. An EmergencyAPI key (free, takes 30 seconds: emergencyapi.com/signup) Basic HTML/JavaScript knowledge Sign up at emergencyapi.com/signup, verify your email, then grab your key from the dashboard. Create an index.html file: html Australian Emergency Map #map { height: 100vh; width: 100%; } Create an app.js file: const API_KEY = 'your_api_key_here'; const API_URL = 'https://emergencyapi.com/api/v1/incidents'; const map = L.map('map').setView([-28, 134], 5); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' }).addTo(map); const colours = { bushfire: '#dc2626', flood: '#2563eb', storm: '#7c3aed', rescue: '#f59e0b', earthquake: '#92400e', medical: '#10b981', other: '#6b7280', }; async function loadIncidents() { const res = await fetch(API_URL, { headers: { 'Authorization': `Bearer ${API_KEY}` } }); const data = await res.json(); data.features.forEach(feature => { const [lng, lat] = feature.geometry.coordinates; const props = feature.properties; const colour = colours[props.eventType] || colours.other; L.circleMarker([lat, lng], { radius: 6, fillColor: colour, color: '#fff', weight: 1, fillOpacity: 0.8 }) .bindPopup(`${props.title}${props.eventType} | ${props.severity}`) .addTo(map); }); } loadIncidents(); setInterval(loadIncidents, 60000); Open index.html in your browser. You should see active emergencies across Australia. Filter by state: add ?state=nsw to the API URL EmergencyAPI aggregates data from official Australian government emergency services. The data may be delayed or incomplete. Always refer to your state emergency service for safety-critical decisions.