My latest creation will show you the weather in your current location using your public ip, or you can enter a zip code and it will return the forecast for that location.
I used a variety of tools including:
- NetBeans IDE
- Weather API (http://openweathermap.org/api)
- Google Maps API (https://developers.google.com/maps/)
- IP Address API (http://ip-api.com)
Let’s go through the logic as briefly as possible.
- Get current location using the IP API via the user’s ip address
- From the location results, extract the latitude and longitude in xml format
- Use this latitude and longitude to run a weather api request also in xml
- Extract information, including the forecast for the next five days
- Display information on the gui.
- If user enters a zip code, do same as above but with zip code
The project includes three classes, WeatherApp, WeatherUtility, and Forecast.
- WeatherApp holds the gui jform as well as the main method.
- WeatherUtility is where all the work is done.
- Forecast is used to create an object of each of the results obtained from the weather api.
View the source files on Github.
Download the app from http://natrivera.com/WeatherApp.jar