prolificinteractive / geocoder

This is a device independent and plugable replacement for Android's builtin Geocoder.
MIT License
6 stars 1 forks source link

Geocoder

This is a device independent and plugable replacement for Android's builtin Geocoder.

A class for handling geocoding and reverse geocoding. 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. The amount of detail in a reverse geocoded location description may vary, for example one might contain the full street address of the closest building, while another might contain only a city name and postal code.

Why

Android's implementation of Geocoder requires the a backend service that is not included in the code android framework. On devices where this backend framework is absent, all calls to the Android Geocoder will silently fail. Additionally, the backend implementation of the android Geocoder may vary across manufacturers, devices and android versions. This library was created to provide a consistent experience across all devices and users.

Installation

Step 1. Add the JitPack repository to your build file

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

Step 2. Add the dependency

dependencies {
    implementation 'com.github.prolificinteractive.geocoder:geocoder:0.1.0'

    // For Geocoder and Google Maps
    implementation 'com.github.prolificinteractive.geocoder:geocoder-googlemaps:0.1.0'

    // For Geocoder and OkHttp
    implementation 'com.github.prolificinteractive.geocoder:geocoder-okhttp:0.1.0'

    // For Geocoder and Open Street Maps
    implementation 'com.github.prolificinteractive.geocoder:geocoder-openstreetmap:0.1.0'
}

Usage

    geocoder = GeocoderBuilder()
        .addGeocodingApi(GoogleMaps.create())
        .setDownloaderFactory(
            OkHttpFactory(OkHttpClient.Builder().build()))
        .build()

    val addresses: List<Address> = geocoder
                                    .getFromLocation("1600 amphitheatre parkway", 1)
                                    .blockingGet()

Roadmap

The pitfalls of the Android Geocoder do not become evident until bad reviews start pouring in. In order for relieve a pain of having to roll your own solution, this project aim to be a drop in replacement for the built in Android Geocoder.

Contributing to Geocoder

To report a bug or enhancement request, feel free to file an issue under the respective heading.

If you wish to contribute to the project, fork this repo and submit a pull request. Code contributions should follow the standards specified in the Prolific Android Style Guide.

License

prolific

geocoder is Copyright (c) 2018 Prolific Interactive. It may be redistributed under the terms specified in the LICENSE file.