The following code will display a Google map with one marker:
<html>
<body>
<p>Blah</p>
<div id="map_canvas" style="width:425px; height:550px"></div>
<p>Blah</p>
<script type="text/javascript" src="
http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var map;
var markers = [];
initialize();
function initialize() {
var myOptions = {
zoom: 10,
center: new google.maps.LatLng(33.7309444, -085.8347333),
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
addMarker(new google.maps.LatLng(33.7309444, -085.8347333), "Alien"); }
function addMarker(latlng, myTitle) {
markers.push(new google.maps.Marker({
position: latlng,
map: map,
title: myTitle,
icon: "
http://maps.google.com/mapfiles/marker" + String.fromCharCode(markers.length + 65) + ".png"
}));
}
</script>
</body>
</html>
Thus bit here:
addMarker(new google.maps.LatLng(33.7309444, -085.8347333), "Alien");places the marker on the map. This line can be repeated with different coordinates to place multiple markers.
I would like to loop through a table a get stored coordinates and duplicate the line above as many times as required to display as many markers as I need.
So, that's my question, how would I loop through a table (I can do that part) and add the lines to the above javascript code?
Thank you!!!
Don