这是java提交经纬度信息,然后获取该经纬度所在省市区的一个方法,话不多说直接上代码:
package com.lmj.util;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import javax.net.ssl.*;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.URL;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
/**
* @author Abell
* @descibe 根据经纬度查询地址信息
* @date 2020/6/20 11:04
*/
public class JingWeiUtil {
/**
* 通过腾讯地图将经纬度转成详细地址
*
* @param lat 纬度
* @param lng 经度
* @return
*/
public static JSONObject getLatAndLng(String lat, String lng) {
try {
String hsUrl = "https://apis.map.qq.com/ws/geocoder/v1/?location=" + lat + "," + lng + "&key=你申请腾讯地图的key值" + "&get_poi=1";
URL url;
url = new URL(hsUrl);
HttpsURLConnection co