package api.jisuapi.coordconvert; import api.util.HttpUtil; import net.sf.json.JSONArray; import net.sf.json.JSONObject; public class Convert { public static final String APPKEY = "your_appkey_here";// 你的appkey public static final String URL = "https://api.jisuapi.com/coordconvert/convert"; public static final String lat = "30,31"; public static final String lng = "120,121"; public static final String from = "1";// 1 WGS坐标系、2 火星坐标系(谷歌、高德、腾讯等)、3 // 百度坐标系、4 伪墨卡托坐标系 public static final String to = "2";// 1 WGS坐标系、2 火星坐标系(谷歌、高德、腾讯等)、3 百度坐标系、4 // 伪墨卡托坐标系 public static void Get() { String result = null; String url = URL + "?lat=" + lat + "&lng=" + lng + "&from=" + from + "&to=" + to + "&appkey=" + APPKEY; try { result = HttpUtil.sendGet(url, "utf-8"); JSONObject json = JSONObject.fromObject(result); if (json.getInt("status") != 0) { System.out.println(json.getString("msg")); } else { JSONObject resultarr = json.optJSONObject("result"); String lat = resultarr.getString("lat"); String lng = resultarr.getString("lng"); String from = resultarr.getString("from"); String to = resultarr.getString("to"); System.out.println(lat + " " + lng + " " + from + " " + to); if (resultarr.opt("list") != null) { JSONArray list = resultarr.optJSONArray("list"); for (int i = 0; i < list.size(); i++) { JSONObject obj = (JSONObject) list.opt(i); String lat_ = obj.getString("lat"); String lng_ = obj.getString("lng"); System.out.println(lat_ + " " + lng_); } } } } catch (Exception e) { e.printStackTrace(); } } }