Gunaseelan
Gunaseelan

Reputation: 15535

Get all places around 2 kilometers using Google's PlaceDetectionApi

I am using following API to get all places from current location,

PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
        .getCurrentPlace(mGoogleApiClient, null);
result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
    @Override
    public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
        Log.v("App",
                "2. likelyPlaces.getCount() : "
                        + likelyPlaces.getCount() + ", placeType : "
                        + placeType);
        places.clear();
        GooglePlace place;
        for (PlaceLikelihood placeLikelihood : likelyPlaces) {                                          
                    place = new GooglePlace();
                    place.setAddress(placeLikelihood.getPlace()
                            .getAddress());
                    place.setId(placeLikelihood.getPlace().getId());
                    place.setLatLng(placeLikelihood.getPlace()
                            .getLatLng());
                    place.setName(placeLikelihood.getPlace().getName());
                    place.setPhoneNumber(placeLikelihood.getPlace()
                            .getPhoneNumber());
                    place.setPriceLevel(placeLikelihood.getPlace()
                            .getPriceLevel());
                    place.setRating(placeLikelihood.getPlace()
                            .getRating());
                    places.add(place);
        }
        mAdapter.notifyDataSetChanged();
        likelyPlaces.release();
    }
});

This one returns only 20 places, and also no photo of the place. So I want to know how to get all places around 2 kilometers from current location. Also how to get the place image.

I know we can get more than 20 results by using

https://maps.googleapis.com/maps/api/place/search/xml?location=Enter Latitude,Enter Longitude&radius=10000&types=store&hasNextPage=true&nextPage()=true&sensor=false&key=enter google_map_key &pagetoken="Enter the first page token Value"

But for this API we have to provide Server IP for get API key. So need to know how can we get more than 20 results by using

PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
        .getCurrentPlace(mGoogleApiClient, null);

Any help will be highly appreciable.

Upvotes: 2

Views: 377

Answers (1)

Kamajabu
Kamajabu

Reputation: 506

Don't know if you found answer already but you should check this out if not:

The Places API will return up to 20 establishments per query; however, each search can return as many as 60 results, split across three pages

https://stackoverflow.com/a/9627664/3677394

Upvotes: 1

Related Questions