D
D
Dilshod952018-09-17 11:55:33
Android
Dilshod95, 2018-09-17 11:55:33

How to get address information in Yandex Map android?

I am using Yandex map 3.0.0 in my android project. I want to get a house, place information from the user's location

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vadim Popov, 2018-09-17
@vadimpopov94

If you use yandex map kit, then here's an example for you, how to get a city with coordinates (longitude and latitude)

private String getCity() {
        Geocoder geocoder = new Geocoder(this, Locale.getDefault());
        try {
            List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);

            if (addresses != null) {
                Address returnedAddress = addresses.get(0);
                city = returnedAddress.getAdminArea().toString();
            } else {
                city = "Error";
            }
        } catch (IOException e) {
            e.printStackTrace();
            city = "Error";
        }
return city;
}

If you need not a city, but something else, then just debug the returnedAddress variable, you will find everything you need there

A
Alexander Varakosov, 2018-09-17
@thelongrunsmoke

Feed the user's coordinates to the geocoder .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question