Skip to content

Dadata.ru address suggestions and geocoding for Android

License

Notifications You must be signed in to change notification settings

illabo/DadataSuggestions

Repository files navigation

DadataSuggestions

It is a dumbed-down Android port of my iOS library of same purpose. Made it to have the ability of convenient reuse of this code. It is primarily intended to be used as a geocoder (forward and reverse) for addresses within Russia.

Usage

There are three methods available suggest, geocode, reverseGeocode.

val dadataClient = DadataSuggestions("YOUR DADATA API TOKEN HERE") 

dadataClient.suggest(
    AddressSuggestionRequest("Новая москва", 3, "ru")
) { Log.d(
    "DADATA ADDR RES",
    it.suggestions.first().unrestricted_value
) } 

dadataClient.reverseGeocode(
    ReverseGeocodeRequest(43.115141, 131.885341, 1)
) { Log.d(
    "DADATA REVGEO RES",
    it.suggestions.first().unrestricted_value
) }

You may also want to add -keepclassmembers class app.illabo.dadatasuggestions.** {*;} to your project's proguard-rules.pro. Sometimes a crash may be occurred if minification is enabled for this library. It happens when the completion passed on calls to DadataSuggestions class' methods raises a NullPointerException in coroutine.

About

Dadata.ru address suggestions and geocoding for Android

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages