Geolocation Code Demo

How it works

Geolocation Request (Google API)

After pressing the button, the application first references the Google Geolocation API to determine your current latitude (distance north or south of the equator) and longitude (distance east or west of Greenwich, England). These are based on your device's IP address or other available location data.

Weather Data Retrieval (OpenWeather API)

Your coordinates are then stored to a variable, whereupon they are referenced within a function that utilizes the OpenWeather API.

The application sends a request to the OpenWeather API using the latitude and longitude variables within the API's key. The OpenWeather API then responds with current weather data for that location.

Data Processing and Display

The application processes the weather data received from the OpenWeather API, extracting the relevant information such as current temperature. This data is then displayed to you on the screen using .innerHTML.

View the weather

You can now view the weather information presented on the web page, providing you with current weather conditions for your current location.