A simple weather application that shows current weather by:
- Your current location (via browser geolocation)
- Any city you search manually
The app uses OpenWeatherMap API data and displays temperature, weather description, wind speed, humidity, cloud coverage, and country flag.
Your Weathertab for location-based weatherSearch Weathertab for city-based weather lookup- Loading state while fetching API data
- Error state with retry button
- Session storage for saved coordinates (
sessionStorage) - Basic accessibility improvements (
alttext, button labels)
- HTML5
- CSS3
- Vanilla JavaScript (ES6+)
- OpenWeatherMap API
- FlagCDN (country flags)
- Google Fonts (
Merriweather Sans)
Weather-App/
|-- index.html
|-- style.css
|-- index.js
|-- README.md
`-- Images/
|-- cloud.png
|-- favicon.ico
|-- humidity.png
|-- loading.gif
|-- location.png
|-- not-found.png
|-- search.png
`-- wind.png
- Clone or download this project.
- Open the project folder.
- Replace API key in
index.js:- Find
const API_KEY = "..."; - Paste your own OpenWeatherMap API key.
- Find
- Run the app:
- Open
index.htmldirectly in your browser, or - Use a local server (recommended), for example VS Code Live Server.
- Open
Get a free API key from OpenWeatherMap:
- Open the app.
- In
Your Weather, click Grant Access to allow location permission. - Switch to
Search Weatherto search weather by city name. - If any request fails, use Retry.
- Temperature is displayed in Celsius (
units=metric). - If geolocation is blocked, location-based weather will not load.
- The app currently uses a client-side API key in
index.js.