Google maps need to show list of addresses -setimout slow and OVER_QUERY_LIMIT issue -


hi have bout 500 addresses or listed in google maps , each address being grabbed filemaker database grouped under category person(employee name in map) i'm using function geocode , i'm calling every 10th time 10 sec setimout, problem is: 1- page very slow settimeout 10sec when have show 500 addresses( addresses can change second never fixed addresses) there better way? 2- settimout set call every 10 seconds, still sporadically over_query_limit , why happen, 10 seconds along time.

here code:

<pre><script type="text/javascript"> var mapoptions = {     //center:mylatlng,     //zoom:15,     maptypeid: google.maps.maptypeid.roadmap }; var map = new google.maps.map(document.getelementbyid("map-canvas"),     mapoptions); //var contentstring='<div id="google_info_window">i;m here</div>'; //var infowindow = new google.maps.infowindow(); var infowindow = new google.maps.infowindow(   {      size: new google.maps.size(150,50)   });  var addresses = new array(); var gmarkers = []; addresses = <?php echo json_encode($project_info); ?>; console.log("addresses: <pre>"+json.stringify(addresses)); <?php //foreach($project_info $i => $val){?>     //addresses.push('<?php //echo $val; ?>'); <?php //}?>  var bounds = new google.maps.latlngbounds(); i=1; mysleepfunction();  function mysleepfunction() { var geocoder = new google.maps.geocoder(); //var mylatlng = new google.maps.latlng(30,-50);  //var contentstring='<div id="google_info_window">i;m here</div>';  //for(var = 0; i<object.keys(addresses).length; i++)  var show_message= document.getelementbyid('map_message'); show_message.style.display="block"; show_message.innerhtml ="<div>loading please wait...</div>";  (; < 200; i++) {     if(i %10 == 0) {          settimeout(geocoder.geocode({'address': addresses[i-1]['address']}, makecallback(i)),2000);           i++;           settimeout("mysleepfunction()",9000);           break;     }     geocoder.geocode({'address': addresses[i-1]['address']}, makecallback(i));     if (i==199){         show_message.style.display = 'none';     } }//for statement     function makecallback(addressindex) {     var = addressindex-1;     var geocodecallback = function(results, status) {          if (status != google.maps.geocoderstatus.ok) {             console.log("geocode not successful following reason: " + status);         } else {             var p = results[0].geometry.location;             var address_formated = results[0].formatted_address;             var appraiser = addresses[i]['staff'];             //var latlng = new google.maps.latlng(p.lat,p.lng);                  map.setcenter(p);             createmarker(map,address_formated,p,appraiser);          // sets center point p             //map.setzoom(10); // sets zoom level             //bounds.extend(latlng);            // main.setmap(map, point, titles[i], bounds);             show(appraiser);         }     }      return geocodecallback; }// function makecallbac  }     //map.setcenter(bounds.getcenter(), map.getboundszoomlevel(bounds));     map.fitbounds(bounds);     // map.pantobounds(bounds);  function createmarker(map,add,p,appraiser) {      var str = add;     var numb=str.indexof(',');     //alert("position of:"+numb);      str =  str.substr(0, numb+1) +"<br/>"+ str.substr(numb+1);     var contentstring = '<div id="google_info_window" style="min-height:40px;height:auto;width:auto;"><strong>'+appraiser+'</strong><p style="margin:1px;padding:5px 1px 2px 1px">'+str+'</p></div>';         //var infowindow = new google.maps.infowindow();         var marker = new google.maps.marker({         map: map,          title:appraiser,         position: p     });      marker.mycategory = appraiser;                                          gmarkers.push(marker);                //open infowindow     google.maps.event.addlistener(marker, 'click', function() {         infowindow.open(map,marker);         infowindow.setcontent(contentstring);     });     marker.setmap(map,bounds); }  // == shows markers of particular category, , ensures checkbox checked == function show(appraiser) {     (var i=0; i<gmarkers.length; i++) {       if (gmarkers[i].mycategory == appraiser) {         gmarkers[i].setvisible(true);       }     }     // == check checkbox ==     var appraiser_id = appraiser.replace(/\s/g,"");     var apraiser_checkbox_id = appraiser_id+"_checkbox";      document.getelementbyid(appraiser_id+"_checkbox").checked = true; } // == hides markers of particular category, , ensures checkbox cleared == function hide(appraiser) {     (var i=0; i<gmarkers.length; i++) {       if (gmarkers[i].mycategory == appraiser) {         gmarkers[i].setvisible(false);       }     }     // == clear checkbox ==     var appraiser_id = appraiser.replace(/\s/g,"");     document.getelementbyid(appraiser_id+"_checkbox").checked = false;     // == close info window, in case open on marker hid     infowindow.close(); }  function boxclick(box,appraiser) {         if (box.checked) {           show(appraiser);         } else {           hide(appraiser);         }         // == rebuild side bar       } // google.maps.event.adddomlistener(window, 'load', initialize); </script></pre> 


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -