百度地圖根據經緯度得到地理位置


String url = "http://api.map.baidu.com/geocoder/v2/?ak=2uZgkxkTV4BCdGfAWN6m3cra&callback=renderReverse&location=39.983424,116.322987&output=json&pois=0";
URL getUrl = new URL(url);
HttpURLConnection connection = (HttpURLConnection) getUrl.openConnection();
connection.connect();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(),"utf-8"));//設置
String result = reader.readLine();
JSONObject json = JSONObject.fromObject(result);
String address= json.getString("result");
json = JSONObject.fromObject(address);
address = json.getString("formatted_address");
System.out.println(address);

 


注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2020 ITdaan.com