给定经纬度,获取位置名称 [英] Given a latitude and longitude, Get the location name

查看:25
本文介绍了给定经纬度,获取位置名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,其中我在我的 android 设备中获取纬度、经度并将它们发布到网络服务器.

I am developing an application wherein I get the latitude, longitude in my android device and post them to a web server.

在网络应用程序中,我借助谷歌地图显示位置详细信息.

and in a web application I show the location details with the help of google maps.

在这里,我收集了大量 lat long 值,我将其循环到我的 jsp 中并使用信息窗口创建多个标记.

Here I have huge collection of lat long values which i loop it in my jsp and create multiple markers with info windows.

现在的问题是我需要在谷歌地图的信息窗口中显示特定纬度和经度的位置名称.

Now the problem is that I need to show the location name of the particular latitude and longitude in the Info Window of google maps.

谁能帮助我使用 google maps 脚本,或者我如何从我的 android 手机本身的 lat long 值中获取位置名称,以便我可以将其发布到我的网络服务器.

Can anyone help me with the google maps script or how can i get the location name from the lat long values in my android phone itself, so that I can post that to my web server.

推荐答案

这里给我一个单,只要在这个函数中传入经纬度就可以得到这个经纬度相关的所有信息.

Here i am given a single just pass the latitude and longitude in this function then you got all the information related to this latitude and longitude.

public void getAddress(double lat, double lng) {
    Geocoder geocoder = new Geocoder(HomeActivity.mContext, Locale.getDefault());
    try {
        List<Address> addresses = geocoder.getFromLocation(lat, lng, 1);
        Address obj = addresses.get(0);
        String add = obj.getAddressLine(0);
        add = add + "
" + obj.getCountryName();
        add = add + "
" + obj.getCountryCode();
        add = add + "
" + obj.getAdminArea();
        add = add + "
" + obj.getPostalCode();
        add = add + "
" + obj.getSubAdminArea();
        add = add + "
" + obj.getLocality();
        add = add + "
" + obj.getSubThoroughfare();

        Log.v("IGA", "Address" + add);
        // Toast.makeText(this, "Address=>" + add,
        // Toast.LENGTH_SHORT).show();

        // TennisAppActivity.showDialog(add);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
    }
}

这篇关于给定经纬度,获取位置名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆