【发布时间】:2016-11-24 13:17:59
【问题描述】:
我正在尝试根据给定查询获取地点。我实现了以下接口。
@GET("api/place/textsearch/json?key=MY_API_KEY")
Call<PlaceResponse> getNearbyPlacesByText(@Query("query") String query, @Query("location") String location, @Query("radius") int radius);
那我这样调用这个方法
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);
然后我正在检索结果。
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) {
}
});
但是我得到了更多与给定查询不匹配的结果(我得到了 20 个位置)。我在 Postman 中尝试使用 URL https://maps.googleapis.com/maps/api/place/textsearch/json?query=psí+škola&location=49.188963,16.532183&radius=50000&key=MY_KEY
我不确定我是否在代码中正确设置了网址。
感谢您的建议 我只有 8 个位置,这是正确的数字。我不确定我是否
【问题讨论】:
标签: android google-maps google-places-api retrofit2