由于纬度和经度,获取地点名称 [英] Given a latitude and longitude, Get the location name

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

问题描述

荫开发一个应用程序,其中我得到的纬度,经度在我的Andr​​oid设备并将其发布到Web服务器。

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

和在Web应用中我表现出与谷歌地图的帮助下位置的详细信息。

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

在这里,我有很大纬度长期价值,我环在我的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.

谁能帮我用谷歌地图脚本或如何我可以从我的Andr​​oid手机本身的经纬度长值获得位置名称,这样我可以张贴到我的网络服务器。

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);
        GUIStatics.currentAddress = obj.getSubAdminArea() + ","
                + obj.getAdminArea();
        GUIStatics.latitude = obj.getLatitude();
        GUIStatics.longitude = obj.getLongitude();
        GUIStatics.currentCity= obj.getSubAdminArea();
        GUIStatics.currentState= obj.getAdminArea();
        add = add + "\n" + obj.getCountryName();
        add = add + "\n" + obj.getCountryCode();
        add = add + "\n" + obj.getAdminArea();
        add = add + "\n" + obj.getPostalCode();
        add = add + "\n" + obj.getSubAdminArea();
        add = add + "\n" + obj.getLocality();
        add = add + "\n" + 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();
    }
}

我希望你有你解答。

I hope you got you answer.

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

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