Skip to content

pelias/pelias-android-sdk

Repository files navigation

Pelias Android SDK

Android SDK for Pelias

Circle CI

Usage

Pelias Android SDK is a client-side Java wrapper for Pelias plus Android specific integrations.

Initialization

The Pelias class provides a simple interface to the Pelias geocoder which can be included in your application.

Pelias pelias = new Pelias();

Suggest

The suggest endpoint provides fast type-ahead autocomplete results.

pelias.suggest("term to search", lat, lon, Callback<Result>);

Search

The search endpoint provides locally and globally relevant full-text search results for addresses and POIs.

pelias.search("term to search", lat, lon, Callback<Result>);

Custom Endpoint

If you have deployed your own instance of Pelias you can set it on the class before initializing.

Pelias pelias = new Pelias("https://your-pelias-domain.com");

Testing

The current strategy for testing involves mocking the service instance using a Retrofit interface which describes the paths to the API.

package com.mapzen.android;

import org.mockito.Mockito;

public class TestPelias extends Pelias {
  public TestPelias(PeliasService service) {
    super(service);
  }
  
  private class TestPeliasService implements PeliasService {
    @Override public Call<Result> getSuggest(@Query("text") String query,
        @Query("focus.point.lat") double lat, @Query("focus.point.lon") double lon) {
      return new TestCall();
    }
    ..
  }
  
  private class TestCall implements Call<Result> {
    @Override public Response<Result> execute() throws IOException {
      return Response.success(new Result());
    }

    @Override public void enqueue(Callback<Result> callback) {
      callback.onResponse(null, Response.success(new Result()));
    }
  }
}

Install

Download Jar

Download the latest AAR.

Maven

Include dependency using Maven.

<dependency>
  <groupId>com.mapzen.android</groupId>
  <artifactId>pelias-android-sdk</artifactId>
  <version>1.3.1</version>
</dependency>

Gradle

Include dependency using Gradle.

compile 'com.mapzen.android:pelias-android-sdk:1.3.1'