Ghost_Stark Ghost_Stark - 1 month ago 43x
Android Question

Google Maps API using Retrofit GET call

I want to pass in the latitude and longitude values to the

attribute of the Google Maps Autocomplete API call but I have no idea how to form the GET call in Retrofit. The URL should ultimately look like this:,-122.44696&radius=50000&key=API_KEY

What I currently have in my Retrofit interface:

public interface GooglePlacesAutoCompleteAPI
String BASE_URL = "";
String API_KEY = "mykey"; //not the actual key obviously

//This one works fine
@GET("json?&types=(cities)&key=" + API_KEY)
Call<PlacesResults> getCityResults(@Query("input") String userInput);

//This is the call that does not work
@GET("json?&types=address&key=" + API_KEY)
Call<PlacesResults> getStreetAddrResults(@Query("input") String userInput,
@Query("location") double latitude, double longitude,
@Query("radius") String radius);

My error is:
java.lang.IllegalArgumentException: No Retrofit annotation found. (parameter #3) for method GooglePlacesAutoCompleteAPI.getStreetAddrResults

So how can I correctly setup the GET method for

Also, are my data types correct for latitude/longitude and radius? Thanks for any help!


Your interface should looks like this:

public interface API {
    String BASE_URL = "";

    Call<PlacesResults> getCityResults(@Query("types") String types, @Query("input") String input, @Query("location") String location, @Query("radius") Integer radius, @Query("key") String key);

And use it like this:

Retrofit retrofit = new Retrofit.Builder()

YourInterface service = retrofit.create(YourInterface.class);

service.getCityResults(types, input, location, radius, key).enqueue(new Callback<PlacesResults>() {
    public void onResponse(Call<PlacesResults> call, Response<PlacesResults> response) {
        PlacesResults places = response.body();

    public void onFailure(Call<PlacesResults> call, Throwable t) {

Of course you should give a value to the parameters.