javascript - getClusters() returning array of length 0 -


var markers = []; (var = 0; < 50; i++) {   var latlng = new google.maps.latlng(30,       40);   var marker = new google.maps.marker({     position: latlng   });   markers.push(marker); } var markercluster = new markerclusterer(map, markers); var arr = markercluster.getclusters(); alert(arr.length); for(var i=0;i<arr.length;i++){     console.log(arr[i].getcenter()); } 

the above code returning array on length 0. why getclusters() not working?

i got reason. need wait time before markercluster created completely.just changed part below.

settimeout(function() {         var arr = markercluster.getclusters();         alert(arr.length);         for(var i=0;i<arr.length;i++){             console.log(arr[i].getcenter());         }        },2000); 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -