A simple web application that displays a map and weather information for a selected location using the OpenWeather API.
- Interactive OpenStreetMap-based map
- Click anywhere on the map to get weather details
- Weather data fetched through a local PHP proxy to keep the API key secure
- Lightweight front-end built with plain HTML, CSS, and JavaScript
weather.html— Main page containing the map and output panelweather.js— Front-end logic for the map and weather requestsproxy.php— PHP proxy that forwards requests to the OpenWeather API using a local environment variable.env— Local API key storage (ignored by Git).gitignore— Prevents sensitive files from being pushed to GitHub
- XAMPP installed on your computer
- PHP with
curlenabled - An OpenWeather API key
- Download and install XAMPP from the official website.
- Open the XAMPP Control Panel.
- Start the Apache module by clicking the Start button next to Apache.
- If prompted, allow the application through your firewall.
- Place this project inside the XAMPP web root folder, usually:
C:/xampp/htdocs/
or on macOS/Linux:
/Applications/XAMPP/xamppfiles/htdocs/
- Create a
.envfile in the project root and add your API key:
WEATHER_API_KEY=your_openweather_api_key_here- Make sure your PHP environment can access the
.envfile andcurlis enabled.
- Open the XAMPP Control Panel.
- Start Apache if it is not already running.
- Open the project in your browser:
http://localhost/project3%202/weather.html
- Click on the map to view the weather for that location.
- If the weather does not load, verify that:
- Apache is running
- PHP is installed and working
- Your API key is valid
- The
.envfile is present in the project root