This is a simple web application that allows users to select a country, state, and city, and then view the current weather for the selected location. The app is fully responsive and uses multiple APIs and local JSON data.
- Cascading selects for Country → State → City
- Fetches coordinates from the selected location
- Displays current weather information including:
- Temperature
- Humidity
- Weather condition
- Wind speed
- Purpose: Convert the selected city, state, and country into latitude and longitude coordinates.
- Endpoint:
https://api.openweathermap.org/geo/1.0/direct?q={city},{state},{country}&limit=1&appid={API_KEY}
- Documentation: Geocoding API
- Purpose: Retrieve current weather information using the coordinates from the Geocoding API.
- Endpoint:
https://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&units=metric&appid={API_KEY}
- Documentation: Weather API
The app uses local JSON files to populate the selects for countries, states, and cities:
countries.json
states.json
cities.json
These files were downloaded from the following repository:
https://github.com/dr5hn/countries-states-cities-database
- Open
index.html
in a browser. - Select a Country from the first dropdown.
- Select a State from the second dropdown.
- Select a City from the third dropdown.
- The weather information will appear below the selectors.
- Vanilla JavaScript (no frameworks required)
- OpenWeatherMap API key (replace
API_KEY
inscript.js
)