json - GMaps API v3 - jQuery - Problems with array -


I am creating a Google map on my web page. There are some markers in this map, with the marker information of a JSN file It all works well but when I want to use a list of all the markers, then this list. The length is always 0 in another function. Only in the ceremony where I put the marker in the list, the list is not empty.

I have created a feeder of my code, so it is more viewable for you.

The problem is with the array "status" and the function button, the button shows the warning in the function, 0. And I do not know why ..

Thanks in advance!

Here's my

This idea is simple, you can call Ajax asyncronously are calling when you are trying to warn the positions.length value, your Ajax is not yet distributed Is going, and your position is not populated with array values ​​and is empty ( .length = 0 ). Enter the button () inside the callback:

  loadMarkers (); //button(); // | // ............. // | // ............. // | // ............. polyline.setMap (map); // --- & gt; button(); });    

Comments