Increase the range of getCurrentPlace

荒凉一梦 提交于 2019-12-13 00:55:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!