What I have: Latitude and Longitude.
What I want: Get weather update for these coordinates.
What I have: Latitude and Longitude.
What I want: Get weather update for these coordinates.
If you want to use the Google Weather API, you'll have to pass it either a City, State or a Zip code. To do this, you'll need to GeoCode your lat/long to get this info.
Here's the URL to the Google Weather API: http://www.google.com/ig/api?weather=Seattle,WA
Here's a sample code to take lat/long and convert to zip:
Geocoder geocoder = new Geocoder(this, Locale.ENGLISH);
List<Address> addresses = null;
try {
addresses = geocoder.getFromLocation(latitude, longitude, 3);
} catch (IOException ex) {
//Handle IOException
}
for (int i = 0; i < addresses.size(); i++) {
Address address = addresses.get(i);
if (address.getPostalCode() != null)
String zipCode = address.getPostalCode();
}
Then pass the Zip Code (Or City, State) to the Google Weather API and parse the returning XML. Good luck!
google API is down, so you should look for an alternative. http://openweathermap.org/api
You need to use an API. You'll have to do some research on your own, here's one good one.
© 2022 - 2024 — McMap. All rights reserved.