I have a MySQL database from which I fetch data to show a marker on my Google map. I would want to show n markers but I don’t know how to implement for-loop so that
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: 'Hello World!',
});
would repeat n-times. I’ve tried adding for loop function but I can’t get it right. I’m only starting to learn JavaScript.
Here’s the rest of the code: http://jsfiddle.net/Wkn9v/7/
Thank you!
I modified your code so the logic is performed in the initialize function, because otherwise the loop wasn’t executing properly. There was some other stuff in the wrong places too. This works:
http://jsfiddle.net/userdude/Wkn9v/13/