在近期的项目中有地址转经纬度的需求,要在地图上进行展示。大多数同事都推荐百度地图,此处特做一个小结,方便使用。百度地图开发者秘钥AK申请此处省略。
百度API官网:http://lbsyun.baidu.com/index.php?title=webapi
直接上代码
package com.jo.common.utils.AddressUtil;
import com.alibaba.fastjson.JSON;
import com.jo.common.utils.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.springframework.stereotype.Component;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
/**
* @author 作者 :d
* @createDa