Question

I have current location Latitude[17.382042000000000000] and Longitude[78.481727299999990000].

Is there any way find out the weather based on these Latitude and Longitude?
Is there any third party free APIs for finding the weather based on these values?
Can any one provide me some guidelines or URLs for this problem?

Was it helpful?

Solution 2

You can use the following URL. Change Latitude and Longitude based on your requirement.

http://api.wunderground.com/auto/wui/geo/GeoLookupXML /index.xml?query=17.3820420000000000006,78.48172729999999000

To get the current weather condition you can use the following API endpoint. The only thing you have to Generate API key from their site. - http://www.wunderground.com/weather/api

Here is the endpoint : http://api.wunderground.com/api/API_KEY/conditions/forecast/alert/q/17.382042000000000000,78.48172729999999000.json

Replace the API_KEY from you generated API key.

OTHER TIPS

Also, I'd recommend to check OpenWeatherMap API. You can use it for free and I think it can help you. For instance, in your case a URL might look like this:

api.openweathermap.org/data/2.5/weather?lat=17.38&lon=78.48

It will return a data in JSON format. For more details please check the API documentation.

+(NSDictionary*)getWeatherForLocation:(CLLocation*)location
{
 NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];

 NSString *stringURL=[NSString stringWithFormat:@"http://api.wunderground.com/api/yourAPIKey/geolookup/forecast10day/q/%f,%f.json",location.coordinate.latitude,location.coordinate.longitude];

 [request setURL:[NSURL URLWithString:stringURL]];

 NSURLResponse * response = nil;
 NSError * error = nil;
 NSData * data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
 NSString *stringData = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

 NSDictionary *dictionary=[stringData objectFromJSONString];

 locationDic=[[NSDictionary alloc] initWithDictionary:[dictionary valueForKey:@"location"]];
 NSLog(@"locations is %@",locationDic);

 return [dictionary valueForKey:@"forecast"];
}

you can directly use api by passing lat long as

http://api.wunderground.com/api/APPKey/geolookup/forecast10day/q/37.785834,-122.406417.json

Yes, there are a few APIs available for this. Look at some of the other StackOverflow questions:

Get weather by html5 geolocation

e.g. Weather bug has an API method that takes lat / long positions:

http://developer.weatherbug.com/docs/read/WeatherBug_API_JSON

I am sure there are many more. Just try a few and see which one works for you.

yahoo provides a weather service - on the iPhone you need to

1) get your longitude & latitude using CoreLocation
2) use

http://query.yahooapis.com/v1/public/yql?q=select+place+from+flickr.places+where+lat=%f+and+lon=%f

to get a woeid (WhereOnEarth ID)

1)use

    http://weather.yahooapis.com/forecastrss?w=%@&u=c

to get your weather report

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top