Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
312 views
in Technique[技术] by (71.8m points)

android - Given a latitude and longitude, Get the location name

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.

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.

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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();
    }
}

I hope you got you answer.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...