4

私は現在の場所の緯度[17.382042000000000000]と経度を持っています[78.481727299999990000].

この緯度と経度から天気を知る方法はありますか?
これらの値に基づいて天気を見つけるためのサードパーティの無料 API はありますか?
この問題のガイドラインや URL を教えてもらえますか?

4

5 に答える 5

4

また、OpenWeatherMap APIを確認することをお勧めします。無料で使えますし、お役に立てると思います。たとえば、あなたの場合、URL は次のようになります。

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

JSON形式でデータを返します。詳細については、API ドキュメントを確認してください。

于 2014-01-03T18:28:50.667 に答える
3

次の 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 を置き換えます。

于 2013-02-18T07:31:39.043 に答える
1
+(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

于 2013-02-18T08:32:04.137 に答える
0

はい、これに使用できる API がいくつかあります。他の StackOverflow の質問をいくつか見てください。

HTML5地理位置情報で天気を取得する

たとえば、天気のバグには、緯度/経度の位置を取る API メソッドがあります。

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

他にもたくさんあると思います。いくつか試してみて、どれが自分に合っているかを確認してください。

于 2013-02-18T07:24:07.623 に答える
0

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

天気予報を取得するには

于 2013-02-18T07:24:56.743 に答える