通过地理位置获取经纬度的简单实现
发布日期:2021-06-28 13:23:47 浏览次数:2 分类:技术文章

本文共 556 字,大约阅读时间需要 1 分钟。

这是通过google原生接口获取的经纬度

public static void getGeoPointBystr(Context context,String str) {
    Address address_temp = null;
    if (str != null) {
        Geocoder gc = new Geocoder(context, Locale.CHINA);
        List<Address> addressList = null;
        try {
            addressList = gc.getFromLocationName(str, 1);
            if (!addressList.isEmpty()) {
                address_temp = addressList.get(0);
                double Latitude = address_temp.getLatitude();
                double Longitude = address_temp.getLongitude();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

 Log.d("wwwwww",str+" Latitude = "+Latitude+" Longitude = "+Longitude);

}

转载地址:https://blog.csdn.net/wwslina/article/details/89714230 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:联通 吉比特无源光纤接入用户端设备(GPON ONU)TEWA-800G超级管理员 如何密码获取
下一篇:Android修改状态栏颜色及字体的工具类(拿走不谢!)

发表评论

最新留言

逛到本站,mark一下
[***.202.152.39]2024年03月31日 20时49分49秒