问题
I'm playing with Google Places API for Android, i tried to retrieve location next to me with this sample :
PendingResult<PlaceLikelihoodBuffer> result =
Places.PlaceDetectionApi.getCurrentPlace(mGoogleApiClient, null);
result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
@Override
public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
Log.d("Hello", "Got results: " + likelyPlaces.getCount() + " place found.");
for (PlaceLikelihood placeLikelihood : likelyPlaces) {
Log.i("Hello", String.format("Place '%s' has likelihood: %g",
placeLikelihood.getPlace().getName(),
placeLikelihood.getLikelihood()));
}
likelyPlaces.release();
}
});
The problem is that it returns only places really next to me, is there a way to increase the range of the places returned by this function ?
回答1:
The idea behind the call is to get the place that the device is currently located at. The only reason it returns a list is because it can't necessarily tell for sure which of the places listed you are currently at. It's not meant to be used for seeing nearby places in a broader sense.
If you want to see what is around you, rather than the exact place you are at, the API does include a handy UI component for that. It is called the PlacePicker.
来源:https://stackoverflow.com/questions/29929019/increase-the-range-of-getcurrentplace