Reputation: 499
I am trying to obtain places according to a given query. I implemented the following interface.
@GET("api/place/textsearch/json?key=MY_API_KEY")
Call<PlaceResponse> getNearbyPlacesByText(@Query("query") String query, @Query("location") String location, @Query("radius") int radius);
Then I call this method like this
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(url)
.addConverterFactory(GsonConverterFactory.create())
.build();
ApiInterface service = retrofit.create(ApiInterface.class);
Call<PlaceResponse> callByText = service.getNearbyPlacesByText("psí" + "škola", currentLocation.getLatitude() + "," + currentLocation.getLongitude(), PROXIMITY_RADIUS);
Then I am retrieving result.
callByText.enqueue(new Callback<PlaceResponse>() {
@Override
public void onResponse(Call<PlaceResponse> call, Response<PlaceResponse> response) {
List<Place> places = response.body().getResults();
Log.d(TAG, "Number of places received: " + places.size());
setMarkers(type, places, googleMap, context);
}
@Override
public void onFailure(Call<PlaceResponse> call, Throwable t) {
}
});
But I get more results that dont match to the given query (I get 20 places). I tried in Postman with the URL https://maps.googleapis.com/maps/api/place/textsearch/json?query=psí+škola&location=49.188963,16.532183&radius=50000&key=MY_KEY
I am not sure if I set the url correctly in my code.
Thanks for any advice I got only 8 places which is correct number. I am not sure if I
Upvotes: 0
Views: 1691
Reputation: 86
You can set logging in Retrofit and check what is being sent (example in Kotlin).
val logging = HttpLoggingInterceptor()
logging.level = HttpLoggingInterceptor.Level.BODY
val httpClient = OkHttpClient.Builder()
httpClient.addInterceptor(logging)
Retrofit.Builder()
.baseUrl(url)
.client(httpClient.build())
.build()
.create(ApiDao::class.java)
Upvotes: 1