android GoogleMap定位(四)(3)
来源:未知 责任编辑:责任编辑 发表时间:2013-11-17 14:39 点击:次
StringBuffer sb =new StringBuffer();
HttpResponse response;
try {
response = client.execute(httpGet);
HttpEntity entity =response.getEntity();
InputStream in=entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
//int len = 0;
//while((len =in.read())!=-1){
// sb.append((char)len);
//}
String line=null;
while ((line = reader.readLine()) != null) {
sb.append(line);
}
in.close();
reader.close();
JSONObject json = new JSONObject(sb.toString());
JSONObject location = json.getJSONArray("results").getJSONObject(0).getJSONObject("geometry").getJSONObject("location");
double x=location.getDouble("lng");
double y = location.getDouble("lat");
return new double[]{x,y};
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}
效果图
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>