Track the International Space Station in real time on an interactive world map using the Where the ISS at? API and Leaflet.js. This project was created as a learning exercise for working with APIs, real-time data, and interactive maps.
- Real-time ISS position updates every second
- Interactive world map with a custom ISS icon
- "Follow ISS" button to toggle automatic map centering
- Displays current latitude and longitude of the ISS
- Background space video and looping audio for an immersive experience
The app fetches the ISS's current position from the API and updates the map marker and coordinates on the page. If "Follow ISS" is enabled, the map automatically centers on the ISS as it moves.
async function getISS() {
try {
const res = await fetch('https://api.wheretheiss.at/v1/satellites/25544');
if (!res.ok) throw new Error('Network response was not ok');
const data = await res.json();
const { latitude, longitude } = data;
document.getElementById('lat').textContent = latitude.toFixed(2);
document.getElementById('lon').textContent = longitude.toFixed(2);
marker.setLatLng([latitude, longitude]);
if (followISS) {
map.setView([latitude, longitude], map.getZoom());
}
} catch (error) {
console.error('Failed to fetch ISS position:', error);
}
}
What this code does:
- Fetches the current ISS position from the API
- Updates the latitude and longitude on the page
- Moves the ISS marker on the map
- If "Follow ISS" is enabled, keeps the map centered on the ISS
space.js
— Main JavaScript logic for fetching data and updating the mapspace.html
— Main HTML file with map, video, and audiospace.json
— Example ISS data (for reference or offline use)audio/space.mp3
— Background audio filevideos/space.mp4
— Background video file
- Clone the repository
- Make sure you have an internet connection (for the API and map tiles)
- Open
space.html
in your browser
Made for fun and learning! You can also contribute.
- To add a 3D mode if possible...:)
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.