阿里云 逆地理编码

 将经纬度转换为详细结构化的地址,且返回附近周边的POI、AOI信息。

阿里云逆地理编码里有示例代码,免费的简单方便,由于导错了一个包耽搁了时间,记录下来以防止以后再有类似错误

package com.ali.sms;

import java.util.HashMap;
import java.util.Map;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;

public class Test1 {
	public static void main(String[] args) {
	    String host = "https://regeo.market.alicloudapi.com";
	    String path = "/v3/geocode/regeo";
	    String method = "GET";
	    String appcode = "你自己的AppCode";
	    Map headers = new HashMap();
	    //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
	    headers.put("Authorization", "APPCODE " + appcode);
	    Map querys = new HashMap();
	    querys.put("batch", "false");//可不写
	    querys.put("callback", "callback");//可不写
	    querys.put("extensions", "base");//可不写
	    querys.put("homeorcorp", "homeorcorp");//可不写
	    querys.put("location", "经度,纬度");
	    querys.put("output", "output");//可不写
	    querys.put("radius", "1000");//可不写
	    querys.put("roadlevel", "roadlevel");//可不写

	    try {
	    	/**
	    	* 重要提示如下:
	    	* HttpUtils请从
	    	* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java
	    	* 下载
	    	*
	    	* 相应的依赖请参照
	    	* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
	    	*/
	    	HttpResponse response =  (HttpResponse) HttpUtils.doGet(host, path, method, headers, querys);
	    	System.out.println(response.toString());
	    	//获取response的body
	    	System.out.println(EntityUtils.toString(response.getEntity()));
	    } catch (Exception e) {
	    	e.printStackTrace();
	    }
	}
}

阿里云的逆地理编码地址:https://market.aliyun.com/products/57002002/cmapi020534.html?spm=5176.2020520132.101.6.25d37218nOX298#sku=yuncode1453400000 

 

你可能感兴趣的:(阿里云)