私は現在の場所の緯度[17.382042000000000000]
と経度を持っています[78.481727299999990000].
この緯度と経度から天気を知る方法はありますか?
これらの値に基づいて天気を見つけるためのサードパーティの無料 API はありますか?
この問題のガイドラインや URL を教えてもらえますか?
私は現在の場所の緯度[17.382042000000000000]
と経度を持っています[78.481727299999990000].
この緯度と経度から天気を知る方法はありますか?
これらの値に基づいて天気を見つけるためのサードパーティの無料 API はありますか?
この問題のガイドラインや URL を教えてもらえますか?
また、OpenWeatherMap APIを確認することをお勧めします。無料で使えますし、お役に立てると思います。たとえば、あなたの場合、URL は次のようになります。
api.openweathermap.org/data/2.5/weather?lat=17.38&lon=78.48
JSON形式でデータを返します。詳細については、API ドキュメントを確認してください。
次の URL を使用できます。必要に応じて緯度と経度を変更します。
http://api.wunderground.com/auto/wui/geo/GeoLookupXML /index.xml?query=17.3820420000000000006,78.48172729999999000
現在の気象条件を取得するには、次の API エンドポイントを使用できます。サイトから API キーを生成する必要があるのは唯一のことです。- http://www.wunderground.com/weather/api
エンドポイントは次のとおりです 。
生成した API キーから API_KEY を置き換えます。
+(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"];
}
latを渡すことでAPIを直接使用できます
http://api.wunderground.com/api/APPKey/geolookup/forecast10day/q/37.785834,-122.406417.json
はい、これに使用できる API がいくつかあります。他の StackOverflow の質問をいくつか見てください。
たとえば、天気のバグには、緯度/経度の位置を取る API メソッドがあります。
http://developer.weatherbug.com/docs/read/WeatherBug_API_JSON
他にもたくさんあると思います。いくつか試してみて、どれが自分に合っているかを確認してください。
yahoo は天気予報サービスを提供しています。iPhone では、
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
天気予報を取得するには