百度地图常用的几个webAPI(中文地址转经纬度,经纬度转中文地址)

本文介绍了如何使用Java实现百度地图的Web API,进行经纬度与中文地址之间的转换。首先展示了通过经纬度获取中文地址的方法,然后演示了如何从中文地址获取经纬度的代码实现。
部署运行你感兴趣的模型镜像

1.根据经纬度获取获取中文地址:

public static EntityBean getaddress(String Lat,String Lng) {

        EntityBean result = new EntityBean();
        try {
            String url = "http://api.map.baidu.com/geocoder/v2/?location="+Lat+","+Lng 
            + "&output=json&ak=wrA6RjC6sH5";
            String json = loadJSON(url);
            EntityBean obj = (EntityBean) JSONSerializer.getInstance().DeSerialize(json, EntityBean.class);
            result = obj;
        } catch (Exception e) {
            Global.getInstance().LogError(e);
        }
        return result;

    }

2.根据中文地址获取经纬度

public static String loadJSON(String url) {
StringBuilder json = new StringBuilder();
try {
URL oracle = new URL(url);
URLConnection yc = oracle.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
String inputLine = null;
while ((inputLine = in.readLine()) != null) {
json.append(inputLine);
}
in.close();
} catch (MalformedURLException e) {
} catch (IOException e) {
}
return json.toString();
}
public static EntityBean getLngAndLat(String address) {
EntityBean result = new EntityBean();
try {
String url = "http://api.map.baidu.com/geocoder/v2/?address=" + address
+ "&output=json&ak=wrA630ClxC6sH5";
String json = loadJSON(url);
EntityBean obj = (EntityBean) JSONSerializer.getInstance().DeSerialize(json, EntityBean.class);
result = obj;
} catch (Exception e) {
Global.getInstance().LogError(e);
}
return result;
}

您可能感兴趣的与本文相关的镜像

Seed-Coder-8B-Base

Seed-Coder-8B-Base

文本生成
Seed-Coder

Seed-Coder是一个功能强大、透明、参数高效的 8B 级开源代码模型系列,包括基础变体、指导变体和推理变体,由字节团队开源

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Java大撕兄

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值