1

I added a pagination, but now it shows 20 places then waits 2s, shows another 20 places and waits again couple sec. I read that Google adds a delay in between nextPage calls. I wounder if there is a way to remove that delay and show 60 places all in once

this.service.search(request, function(results, status, pagination) {
            self.addPlaces(results, status, pagination);

            if (pagination.hasNextPage) {
                // sleep:0; this doesn't effect anything
                pagination.nextPage();
            }                           
});
Stewie Griffin
  • 9,257
  • 22
  • 70
  • 97

3 Answers3

2

There is no way to remove that delay, but a turnaround would be displaying a progressBar to the users or pre-fetching before showing it to the users. You can see my answer, I am using AsyncTask to call the request method at the background and displaying a progressBar till it fetches all the 60 results.

Community
  • 1
  • 1
shreks7
  • 422
  • 4
  • 10
1

There is no way to remove the two second delay between additional page requests. This is put in place due to data provider restrictions to limit developers to only show 20 results at a time unless the user requests more results.

As stated in the Google Maps Javascript API v3 Places Library Documentation:

"Each page of results must be displayed before displaying the next page of results."

Chris Green
  • 4,397
  • 1
  • 23
  • 21
0

It's advantageous to reducing calls to not only stick with 20 results, but also to consider adding a delay on the query. Adding a 500ms delay has reduced requests by 20% on a project I work with.

Travis
  • 124
  • 1
  • 9