I am building an google map on my web page. This map has some markers. These markers are created with information of a json file. This all works fine. But when I want to use a list of all markers, this list.length is always 0 in an other function. Only in the function where i put the markers into the list, the list isn’t empty.
I made a fidler of my code, so it’s more viewable for you guys.
The problem is with the array “positions” and the function buttons.
The alert in the buttons function, shows 0. And I have no idea why..
Thanks in advance!
Here my Fiddle
The idea is simple. You are calling
Ajaxasyncronously. When you are trying to alertpositions.lengthvalue, yourAjaxis not being delivered yet,and yourpositionarray is not populated with values and is empty(.length=0). Putbuttons()call inside of the callback: