1 //根據(jù)經(jīng)緯度獲取城市名
public static String getCityNameByLan(String lng,String lat){
try{
String url="http://api.map.baidu.com/geocoder?location="+lat+","+lng+"&output=json";
MyHttpClientResponseResult r= MyHttpClientUtil.requestGet(url);
String s = r.getResponseContent();
JSONObject k = JSONObject.parseObject(s);
String t = k.getJSONObject("result").getJSONObject("addressComponent").getString("city");
return t;
}catch (Exception e){
return "1";
}
}
2 根據(jù)城市獲取天氣數(shù)據(jù)
MyHttpClientResponseResult r= MyHttpClientUtil.requestGet("http://wthrcdn.etouch.cn/weather_mini?city="+city);