/**
* 根据坐标获取具体地址
* @param coor 坐标字符串
* @return
*/
public static String getAdd(String coor){
String urlString = "http://restapi.amap.com/v3/geocode/regeo?key=8325164e247e15eea68b59e89200988b&s=rsv3&location="+coor+"&radius=2800&callback=jsonp_452865_&platform=JS&logversion=2.0&sdkversion=1.3&appname=http%3A%2F%2Flbs.amap.com%2Fconsole%2Fshow%2Fpicker&csid=49851531-2AE3-4A3B-A8C8-675A69BCA316";
String res = "";
try {
URL url = new URL(urlString);
java.net.HttpURLConnection conn = (java.net.HttpURLConnection)url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("GET");
java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(conn.getInputStream(),"UTF-8"));
String line;
while ((line = in.readLine()) != null) {
res += line+"\n";
}
in.close();
} catch (Exception e) {
System.out.println("error in wapaction,and e is " + e.getMessage());
}
System.out.println(res);
return res;
}
/**
* 根据地名获取坐标
* @param
*/
public static String getCoor(String address){
String urlString = "http://restapi.amap.com/v3/place/text?s=rsv3&children=&key=8325164e247e15eea68b59e89200988b&page=1&offset=10&city=610100&language=zh_cn&callback=jsonp_25126_&platform=JS&logversion=2.0&sdkversion=1.3&appname=http%3A%2F%2Flbs.amap.com%2Fconsole%2Fshow%2Fpicker&csid=19FA0D45-180F-4D45-BCB4-C6C265F55FF6&keywords="+address;
String res = "";
try {
//http://restapi.amap.com/v3/geocode/regeo?key=8325164e247e15eea68b59e89200988b&s=rsv3&location=101.539737903028,36.79828256329313&radius=2800&callback=jsonp_452865_&platform=JS&logversion=2.0&sdkversion=1.3&appname=http%3A%2F%2Flbs.amap.com%2Fconsole%2Fshow%2Fpicker&csid=49851531-2AE3-4A3B-A8C8-675A69BCA316
URL url = new URL(urlString);
java.net.HttpURLConnection conn = (java.net.HttpURLConnection)url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("GET");
java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(conn.getInputStream(),"UTF-8"));
String line;
while ((line = in.readLine()) != null) {
res += line+"\n";
}
in.close();
} catch (Exception e) {
System.out.println("error in wapaction,and e is " + e.getMessage());
}
System.out.println(res);
return res;
}
public static void main(String[] agrs) {
String add = getAdd("101.539737903028,36.79828256329313");
String json = add.substring(add.indexOf("(")+1,add.lastIndexOf(")"));
JSONObject jsonObject = JSONObject.fromObject(json);
jsonObject = JSONObject.fromObject(jsonObject.get("regeocode"));
System.out.println(jsonObject.getString("formatted_address"));\
String coor = getCoor("西宁市");
System.out.println(coor);
 } 

运行结果:

青海省西宁市湟中县李家山镇拦李公路
jsonp_25126_({"status":"1","count":"513","info":"OK","infocode":"10000","suggestion":{"keywords":[],"cities":[]},"pois":[{"id":"B03CB0SN18","name":"西宁市","type":"地名地址信息;普通地名;地市级地名","typecode":"190104","biz_type":[],"address":"城中区","location":"101.778112,36.617042","tel":[],"distance":[],"biz_ext":{"rating":[],"cost":[]},"pname":"青海省","cityname":"西宁市","adname":"城中区","importance":[],"shopid":[],"shopinfo":"2","poiweight":[]},{"id":"B03CB10608","name":"西宁市口腔医院(香格里拉路)","type":"医疗保健服务;专科医院;口腔医院","typecode":"090202","biz_type":[],"address":"福路巷16号","location":"101.753742,36.598270","tel":"0971-8213133","distance":[],"biz_ext":{"rating":[],"cost":[]},"pname":"青海省","cityname":"西宁市","adname":"城中区","importance":[],"shopid":[],"shopinfo":"2","poiweight":[]},{"id":"B0FFG4AXXD","name":"西宁市第二十一中学","type":"科教文化服务;学校;中学","typecode":"141202","biz_type":[],"address":"柴达木路386号","location":"101.681923,36.663087","tel":[],"distance":[],"biz_ext":{"rating":[],"cost":[]},"pname":"青海省","cityname":"西宁市","adname":"城北区","importance":[],"shopid":[],"shopinfo":"0","poiweight":[]},{"id":"B03CB01D43","name":"西宁市人民政府","type":"政府机构及社会团体;政府机关;地市级政府及事业单位","typecode":"130103","biz_type":[],"address":"南关街43号","location":"101.778112,36.617042","tel":"0971-8230424","distance":[],"biz_ext":{"rating":[],"cost":[]},"pname":"青海省","cityname":"西宁市","adname":"城中区","importance":[],"shopid":[],"shopinfo":"2","poiweight":[]},{"id":"B03CB04AE8","name":"西宁市财政局","type":"政府机构及社会团体;政府机关;地市级政府及事业单位","typecode":"130103","biz_type":[],"address":"五四西路11号","location":"101.749706,36.634725","tel":"0971-6310710","distance":[],"biz_ext":{"rating":[],"cost":[]},"pname":"青海省","cityname":"西宁市","adname":"城西区","importance":[],"shopid":[],"shopinfo":"2","poiweight":[]},{"id":"B03CB108ZK","name":"西宁市中医院","type":"医疗保健服务;综合医院;综合医院","typecode":"090100","biz_type":[],"address":"生物园区经一路20号","location":"101.751826,36.688383","tel":[],"distance":[],"biz_ext":{"rating":"1.0","cost":[]},"pname":"青海省","cityname":"西宁市","adname":"城北区","importance":[],"shopid":[],"shopinfo":"2","poiweight":[]},{"id":"B03CB06R0R","name":"西宁市殡仪馆","type":"生活服务;丧葬设施;殡仪馆","typecode":"071903","biz_type":[],"address":"宁互公路","location":"101.875836,36.605621","tel":"0971-5130150","distance":[],"biz_ext":{"rating":"3.9","cost":[]},"pname":"青海省","cityname":"西宁市","adname":"城东区","importance":[],"shopid":[],"shopinfo":"0","poiweight":[]},{"id":"B03CB04659","name":"西宁市地税局","type":"政府机构及社会团体;工商税务机构;地税机关","typecode":"130703","biz_type":[],"address":"西关大街街道昆仑路9号锦绣城","location":"101.763260,36.621090","tel":[],"distance":[],"biz_ext":{"rating":[],"cost":[]},"pname":"青海省","cityname":"西宁市","adname":"城西区","importance":[],"shopid":[],"shopinfo":"2","poiweight":[]},{"id":"B03CB06ZDJ","name":"西宁市交通局","type":"政府机构及社会团体;政府机关;地市级政府及事业单位","typecode":"130103","biz_type":[],"address":"五四大街28号","location":"101.767748,36.628084","tel":"0971-6145937","distance":[],"biz_ext":{"rating":[],"cost":[]},"pname":"青海省","cityname":"西宁市","adname":"城西区","importance":[],"shopid":[],"shopinfo":"2","poiweight":[]},{"id":"B03CB04420","name":"西宁市民政局","type":"政府机构及社会团体;政府机关;地市级政府及事业单位","typecode":"130103","biz_type":[],"address":"海晏路2号国贸大厦","location":"101.756503,36.639296","tel":"0971-8295867","distance":[],"biz_ext":{"rating":[],"cost":[]},"pname":"青海省","cityname":"西宁市","adname":"城西区","importance":[],"shopid":[],"shopinfo":"2","poiweight":[]}]})


干货分享,请笑纳,方法还有待优化

根据高德API知道坐标获取详细地址信息的更多相关文章

  1. 高德amap 根据坐标获取的地址信息

    高德地理逆地理编码接口List<List<Address>> lists = coder.getFromLocation(33.00, 116.500, 3, 3, 3, 50 ...

  2. Android Google Maps API 网络服务用于网络定位、计算路线、获取经纬度、获取详细地址等

    extends:http://blog.csdn.net/h7870181/article/details/12505883 Google Maps API 网络服务 官网地址 : https://d ...

  3. Android使用百度定位API时获取的地址信息为null

    option.setAddrType("all"); //加上这个配置后才可以取到详细地址信息

  4. android 基于百度地图api开发定位以及获取详细地址

    一:百度地图开发必须要到百度开发平台android开发api下载相应的库,已经申请百度地图开发key. 二:新建项目baidumaplocation.设计main.xml文件这里注意的是MapView ...

  5. 调用高德API,通过输入的地址,如省份、市、区获取经纬度 ,通过输入的经纬度,获取区域详情

    一.pom <?xml version="1.0" encoding="UTF-8"?><projectxmlns="http:// ...

  6. JAVA使用经纬度通过腾讯地图API获取详细地址

    官方文档:https://lbs.qq.com/service/webService/webServiceGuide/webServiceGcoder package com.weixin.map; ...

  7. Vue中使用百度地图——根据输入框输入的内容,获取详细地址

    知识点:在Vue.js项目中调用百度地图API,实现input框,输入地址,在百度地图上定位到准确地址,获得到经纬度 参考博客:  百度地图的引用,初步了解参考博客:http://blog.csdn. ...

  8. iOS之获取经纬度并通过反向地理编码获取详细地址

    _locationManager = [[CLLocationManager alloc] init]; //期望的经度 _locationManager.desiredAccuracy = kCLL ...

  9. CoreLocation+MapKit系统定位(含坐标以及详细地址)

    iOS8 之后出现一些新的配置 [self.manager requestWhenInUseAuthorization]; 并且在info.plist文件中增加 NSLocationWhenInUse ...

随机推荐

  1. bulk-load 装载HDFS数据到HBase

    bulk-load的作用是用mapreduce的方式将hdfs上的文件装载到hbase中,对于海量数据装载入hbase非常有用,参考http://hbase.apache.org/docs/r0.89 ...

  2. 和菜鸟一起学linux总线驱动之i2c死锁问题

    不知不觉中已经有好几个月没有写点东西了,懒了就是懒了,说是忙着想把产品做得更好,都是借口,每天花一点时间来写点东西确实很不错,自己也坚持了很久很久,只不过今年以来,发现提高不是很大,能写的东西好少好少 ...

  3. How--to-deploy-smart-contracts-on

    The following smart contract code is only an example and is NOT to be used in Production systems. pr ...

  4. aside元素

    aside元素用来表示当前页面或文章的附属信息部分,它可以包含与当前页面或主要内容相关的引用.侧边栏.广告.导航条,以及其他类似的有别于主要内容的部分. aside元素主要有以下两种使用方法: 1.包 ...

  5. xmlrpc

    xmlrpc编辑 官方URL:http://ws.apache.org/xmlrpc/xmlrpc2/index.html 本词条缺少名片图,补充相关内容使词条更完整,还能快速升级,赶紧来编辑吧! x ...

  6. java核心卷轴之集合

    1. Iterator 1.1 注意事项 接口的remove方法将删除上次调用next方式时返回的对象,即:remove之前,必须有next(先获取,再删除). 1.2 例一:删除字符串集合中的第一个 ...

  7. C语言代码

    //计算1/1+1/ (1+2) +1/ (1+2+3) +…+1/(1+2+…n)的值,要求小数点后保留6位,n从键盘输入 #include<stdio.h> main(){ ; ; i ...

  8. 下载Github上某个项目的子文件夹和单个文件

    preface Github下的项目可能很大,里面有很多的子文件夹,我们可能只需要使用某个子目录下的资源,可以不用下载完整的repo就能使用. 例如,我想下载这个repo中的字典文件:https:// ...

  9. 算法库中heap应用

    STL中make_heap 的接口为: default (1) template <class RandomAccessIterator> void make_heap (RandomAc ...

  10. 【leetcode】 算法题 两数之和

      问题       给定一个整数数组和一个目标值,找出数组中和为目标值的两个数. 你可以假设每个输入只对应一种答案,且同样的元素不能被重复利用. 示例: 给定 nums = [2, 7, 11, 1 ...