I have this code where I display and set all my markers. How can I add a popup with some information on markers with this code? I add \"i\" variable on text, but it sets on all
That's because the variable i
is not used in the loop but when the marker is clicked -- and then i is equal to the last index + 1... The addListener
is asynchronous, not synchronous.
Remove infowindow.setContent('test: ' + i + '');
and replace content: " "
with content: 'test: ' + i
. This should fix your problem.