importjava.io.BufferedReader;importjava.io.IOException;importjava.io.InputStreamReader;importjava.net.MalformedURLException;importjava.net.URL;importjava.net.URLConnection;importcom.google.gson.JsonElement;importcom.google.gson.JsonObject;importcom.google.gson.JsonParser;public classGetAdreesByLatAndLong {/***
* Title: GetLocationMsg
*
*
* Description:高德地图API
*
*
*@paramlongitude
*@paramlatitude
*@return
*/
public static String GetLocationMsg(double longitude, doublelatitude) {
String message= "";
String address= "";//高德地图逆地理编码API
String url=String.format("https://restapi.amap.com/v3/geocode/regeo?output=JSON&key=你的key&radius=1000&extensions=all&batch=false&roadlevel=0&location=%s,%s",
longitude, latitude);
URL myURL= null;
URLConnection httpsConn= null;try{
myURL= newURL(url);
}catch(MalformedURLException e) {
e.printStackTrace();
}try{
httpsConn=(URLConnection) myURL.openConnection();
httpsConn.setConnectTimeout(100000);if (httpsConn != null) {
InputStreamReader insr= newInputStreamReader(
httpsConn.getInputStream(),"UTF-8");
BufferedReader br= newBufferedReader(insr);
String data= null;while ((data = br.readLine()) != null) {
message= message +data;
}
JsonParser jp=