javascript - searchBox Google Maps with pagination -


so trying implement google maps search box. currently, search box retrieves 20 of top places based on search result.

what noticed there no pagination this. such if type in “pizza”, give me top 20 results in current location bounds. when use google.maps.places.placesservice(map) textsearch function obtain list of pizza searches, more 20 results pagination.

is there way pagination on searchbox or use textsearch function provide pagination after used searchbox?

what have here snippet:

var canvas = element.find('div')[0]; var mapoptions = {     zoom: 5,     minzoom: 2, }; var searchbox = new google.maps.places.searchbox('pizza'); var placeservice = new google.maps.places.placesservice(map);  google.maps.event.addlistener(searchbox, 'places_changed', locationchange);  function locationchange() {     var places = searchbox.getplaces();     //determine if there additional places not provided searchbox. using text      var request = {         query: input.value,     };     var textsearchplaces = placeservice.textsearch(request, callback);     function callback(results, status, pagination) {         if (status == google.maps.places.placesservicestatus.ok) {             var hi = places;             (var = 0; < results.length; i++) {                 var place = results[i];             }         }     }     if (places.length === 0) {         return;     } }; 

as can see not ideal solution looking using pagination have filter through textsearchplaces see if places not duplicates of searchbox results.

i thought removing searchbox , going textsearch function realized wouldn’t have autocomplete function provides suggestions searchbox provides.

most getting over_query_limit.

if (status == google.maps.places.placesservicestatus.ok) {

try queuing details requests after have list completed, adding same timeout logic check google.maps.places.placesservicestatus.over_query_limit on line.

if (pagination.hasnextpage) { //add places list settimeout('pagination.nextpage()',2000); }  else { createmarkers(placeslist); } 

you should use google.maps.places.placesservicestatus.over_query_limit when using places.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -