Android SDK for Pelias
Pelias Android SDK is a client-side Java wrapper for Pelias plus Android specific integrations.
The Pelias
class provides a simple interface to the Pelias geocoder which can be included in your application.
Pelias pelias = new Pelias();
The suggest endpoint provides fast type-ahead autocomplete results.
pelias.suggest("term to search", lat, lon, Callback<Result>);
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>);
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");
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()));
}
}
}
Download the latest AAR.
Include dependency using Maven.
<dependency>
<groupId>com.mapzen.android</groupId>
<artifactId>pelias-android-sdk</artifactId>
<version>1.3.1</version>
</dependency>
Include dependency using Gradle.
compile 'com.mapzen.android:pelias-android-sdk:1.3.1'