使用Google Weather API查詢天氣預(yù)報
Google Weather API 只支持美國地區(qū)使用郵政編碼進(jìn)行查詢,例如:
http://www.google.com/ig/api?hl=zh-cn&weather=94043
(94043 為 山景城, 美國加州 的郵政編碼)
而除了美國以外的地區(qū)需要使用經(jīng)緯度坐標(biāo)作為參數(shù)才能執(zhí)行 Google Weather API, 例如:
http://www.google.com/ig/api?hl=zh-cn&weather=,,,30670000,104019996
(30670000,104019996 為 成都, 中國大陸 的經(jīng)緯度坐標(biāo))
當(dāng)然,也可能通行城市名稱的漢語拼音來查詢,例如:以下是北京的天氣
http://www.google.com/ig/api?hl=zh-cn&weather=Beijing
要其它地區(qū)的經(jīng)緯度坐標(biāo),可以通過 Google API 提供的國家代碼列表及相應(yīng)的城市經(jīng)緯度坐標(biāo)列表可以查詢到,以下是 Google API 提供的查詢參數(shù):
http://www.google.com/ig/countries?output=xml&hl=zh-cn
(查詢 Google 所支持的所有國家的代碼,并以 zh-cn 簡體中文顯示)
http://www.google.com/ig/cities?output=xml&hl=zh-cn&country=cn
新浪微博:http://t.sina.com.cn/androidguy 昵稱:李寧_Lining
http://www.google.com/ig/api?hl=zh-cn&weather=94043
(94043 為 山景城, 美國加州 的郵政編碼)
而除了美國以外的地區(qū)需要使用經(jīng)緯度坐標(biāo)作為參數(shù)才能執(zhí)行 Google Weather API, 例如:
http://www.google.com/ig/api?hl=zh-cn&weather=,,,30670000,104019996
(30670000,104019996 為 成都, 中國大陸 的經(jīng)緯度坐標(biāo))
當(dāng)然,也可能通行城市名稱的漢語拼音來查詢,例如:以下是北京的天氣
http://www.google.com/ig/api?hl=zh-cn&weather=Beijing
要其它地區(qū)的經(jīng)緯度坐標(biāo),可以通過 Google API 提供的國家代碼列表及相應(yīng)的城市經(jīng)緯度坐標(biāo)列表可以查詢到,以下是 Google API 提供的查詢參數(shù):
http://www.google.com/ig/countries?output=xml&hl=zh-cn
(查詢 Google 所支持的所有國家的代碼,并以 zh-cn 簡體中文顯示)
http://www.google.com/ig/cities?output=xml&hl=zh-cn&country=cn
《Android開發(fā)完全講義(第2版)》(本書版權(quán)已輸出到臺灣)
http://product.dangdang.com/product.aspx?product_id=22741502
《Android高薪之路:Android程序員面試寶典 》http://book.360buy.com/10970314.html
新浪微博:http://t.sina.com.cn/androidguy 昵稱:李寧_Lining
posted on 2009-09-02 10:26 銀河使者 閱讀(3645) 評論(1) 編輯 收藏 所屬分類: Google