| | |
| | | import java.io.IOException; |
| | | public class GaoDeMapUtil { |
| | | |
| | | // public static void main(String[] args) { |
| | | // // 地址名称 |
| | | // String address = "深圳市"; |
| | | // // 调用自己写好的封装方法 |
| | | // JSONObject positionObj = getLngAndLat(address); |
| | | // String longitude = positionObj.getString("longitude"); |
| | | // String latitude = positionObj.getString("latitude"); |
| | | // System.out.println("经度:" + longitude); |
| | | // System.out.println("纬度:" + latitude); |
| | | // |
| | | // } |
| | | |
| | | |
| | | /** |
| | | * 根据地址查询经纬度 |
| | |
| | | CloseableHttpClient httpclient = HttpClients.createDefault(); |
| | | try { |
| | | // 拼接请求高德的url |
| | | HttpGet httpget = new HttpGet(address+"&sensor=false&key=AIzaSyCnvS7Xm3utDjc2fdd5Gvk5E1-bavcrzAA"); |
| | | HttpGet httpget = new HttpGet(address+"&sensor=false&key=77b37f0753049c4e712ea79a24e0719c"); |
| | | // 执行get请求. |
| | | CloseableHttpResponse response = httpclient.execute(httpget); |
| | | |