谷歌Places API的PlaceFilter [英] Google Places API PlaceFilter
问题描述
我使用谷歌Android Places API的,我试图限制结果,只显示餐馆。我已经包括一个PlaceFilter,似乎是正确的,但似乎并没有被应用滤镜和餐厅一边给其他结果。见code:
I am using Google Places API for Android and am trying to limit the results to only show Restaurants. I have included a PlaceFilter and seems to be correct but doesn't seem to be applying the filter and giving other results aside from Restaurants. See code:
ArrayList<String> restrictToRestaurants = new ArrayList<>();
restrictToRestaurants.add(Integer.toString(Place.TYPE_RESTAURANT));
PlaceFilter pf;
pf = new PlaceFilter(false, restrictToRestaurants);
PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi.getCurrentPlace(mGoogleApiClient, pf);
result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
@Override
public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
for (PlaceLikelihood placeLikelihood : likelyPlaces) {
placeLikelihood.getPlace().getPlaceTypes();
Log.i(TAG, String.format("Place '%s' with " + "likelihood: %g", placeLikelihood.getPlace().getName(), placeLikelihood.getLikelihood()));
}
likelyPlaces.release();
}
});
任何人有任何想法如何运用PlaceFilter?
Anyone have any ideas how to apply the PlaceFilter?
推荐答案
目前,过滤 getCurrentPlace
的结果的唯一方式是列出的<一href=\"https://developer.android.com/reference/com/google/android/gms/location/places/PlaceFilter.html\"相对=nofollow> PlaceFilter 类:
Currently, the only ways to filter the results of getCurrentPlace
are outlined in the PlaceFilter class:
requireOpenNow 如果为true,只返回地方现在打开
requireOpenNow if true, return only places open now
restrictToPlaceIds 的具体PlaceIds匹配
restrictToPlaceIds the specific PlaceIds to match
那些PlaceIds中的每一个被认为匹配到特定的位置。不幸的是,它看起来像的地方类型过滤 Places.PlaceDetectionApi.getCurrentPlace
的结果(如餐厅)不被支持。在你引用可在<一个使用 Place.TYPE_RESTAURANT
href=\"https://developer.android.com/reference/com/google/android/gms/location/places/AutocompleteFilter.html\"相对=nofollow> AutocompleteFilter 为 GeoDataApi.getAutocomplete predictions
。
Each one of those PlaceIds is supposed to match to a specific location. Unfortunately, it looks like filtering the results of Places.PlaceDetectionApi.getCurrentPlace
by the type of place (eg restaurants) is not supported yet. The Place.TYPE_RESTAURANT
you referenced can be used in AutocompleteFilter for GeoDataApi.getAutocompletePredictions
.
这篇关于谷歌Places API的PlaceFilter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!