Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android how to get the street name from an address returned by Geocoder

I'm using Geocoder in reverse way to get an address from a given lat & lon.

Do you know how to get from Address only the street name?

    Geocoder geocoder = new Geocoder(AutoFinderMapActivity.this);
    try {
        List<Address> addressList = geocoder.getFromLocation(latitude, longitude, 1);
        if (addressList != null && addressList.size() > 0) {
            // Help here to get only the street name
            String adress = addressList.get(0).get...;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

Thanks in advance,

like image 1000
Jorge Gil Avatar asked Sep 14 '12 05:09

Jorge Gil


People also ask

How do I find a street name from latitude and longitude?

Use getLocality() and getCountryName() instead. @Shubh - Try this url - "http://maps.googleapis.com/maps/api/geocode/json?latlng=" + latitude + ","+ longitude + "&sensor=true" . It will return Json response. You don't need to specify Locale.

How do you find the geocoding of an address?

The Geocoding toolbar provides a quick way to search for an address and display the corresponding location on a map. If the Geocoding toolbar has not been added to ArcMap, click Customize > Toolbars > Geocoding to add it. Click the first drop-down arrow and choose an address locator.

What is the difference between geocoding and reverse geocoding in Android?

Geocoding is the process of transforming a street address or other description of a location into a (latitude, longitude) coordinate. Reverse geocoding is the process of transforming a (latitude, longitude) coordinate into a (partial) address.

What is geocoder location?

Geocoding is the process of converting addresses (like "1600 Amphitheatre Parkway, Mountain View, CA") into geographic coordinates (like latitude 37.423021 and longitude -122.083739), which you can use to place markers on a map, or position the map.


1 Answers

I was searching up the very same thing. I disagree with the answer that was marked as correct. I could be wrong but it would appear that "Thoroughfare" (what a quaint old English term!) is the field that provides the street name. so for example:

get the addresses:

    List<Address> addresses = null;
    addresses = geocoder.getFromLocation(latitude, longitude,1);
    if(addresses != null && addresses.size() > 0 ){
       Address address = addresses.get(0);
       // Thoroughfare seems to be the street name without numbers
            String street = address.getThoroughfare();
    }
like image 99
joe_developer Avatar answered Nov 16 '22 04:11

joe_developer