/**
* 根据坐标获取具体地址
* @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. 《老罗的Android之旅》导读PPT

    虽然好几个月没更新博客了,但是老罗一直有在准备可以分享的东西的.除了早前在微博分享Android4.2相关技术之外,这次还特意准备了13个PPT,总结之前所研究过的东西.内容从Android组件设计思 ...

  2. redis存入中文,取出来显示不正常

    问题: 127.0.0.1:6379> set name 张泰松OK127.0.0.1:6379> get name"\xe5\xbc\xa0\xe6\xb3\xb0\xe6\x ...

  3. leetcode刷题指南

    转载自:http://blog.csdn.net/lnho2015/article/details/50962989 以下是我个人做题过程中的一些体会: 1. LeetCode的题库越来越大,截止到目 ...

  4. js 读取xml文件

    读取xml文件 [原创 2007-6-20 17:35:37]     字号:大 中 小 js中读取xml文件,简单的例子: <html><head><script> ...

  5. java之Spring(IOC)注解装配Bean详解

    在这里我们要详细说明一下利用Annotation-注解来装配Bean. 因为如果你学会了注解,你就再也不愿意去手动配置xml文件了,下面就看看Annotation的魅力所在吧. 先来看看之前的bean ...

  6. UE4中如何使物体始终朝向摄像头?

    要使物体始终正面朝向摄像头需要用到一个关键节点:Find Look at Rotation 其中Start连接需要旋转的物体位置矢量,Target连接摄像头位置矢量 最后设置SetActorRotat ...

  7. Spring HTTP状态码枚举值对照表

    使用Spring时总去查HTTP状态码对应的Spring枚举值的那篇代码,有点不方便,把代码拷贝出来统一替换格式做成了表格,放在这里,方便大家使用.(枚举类为HttpStatus) 枚举值 HTTP状 ...

  8. 关于Spring的HibernateTemplate的findByExample方法使用时的一点注意。

    此前我们已经介绍了HibernateTemplate的使用配置方法,但是对其使用没有仔细说明.因为最近比较忙,我先不去介绍,而是重点说明一下容易引起问题的findByExample方法. 我尝试反编译 ...

  9. GenyMotion 配合 Android Studio 的安装

    众所周知,Android Studio 自带的模拟器对内存和CPU消耗都很大却并没有很好的效果,简直是谷歌为了卖手机设计的.而Geny Motion 对机能的要求大大降低,又不会像自带模拟器那么卡.G ...

  10. ASP.NET中直接用C# 动态修改CSS样式

    ASP.NET中直接用C# 动态修改CSS样式  wonsoft (wonsoft@163.com) 使用JavaScript控制CSS样式有点麻烦,还是觉得直接使用C#操作更方便快捷,本文通过两个B ...