<script type="text/javascript">function initialize() {var center = new google.maps.LatLng(54.385756, -4.465256);var map = new google.maps.Map(document.getElementById('map'), {zoom: 5,center: center,mapTypeId: google.maps.MapTypeId.ROADMAP});var markers = [];for (var i = 0; i < 100; i++) {var dataPhoto = data.posts[i];var latLng = new google.maps.LatLng(dataPhoto.latitude,dataPhoto.longitude);var marker = new google.maps.Marker({position: latLng});markers.push(marker);}var markerCluster = new MarkerClusterer(map, markers);var contentString = '<div id="content">'+'<div id="siteNotice">'+'</div>'+'<h1 id="firstHeading" class="firstHeading">Uluru</h1>'+'<div id="bodyContent">'+'<p><b>Uluru</b>, also referred to as <b>Ayers Rock</b>, is a large ' +'sandstone rock formation in the southern part of the '+'Northern Territory, central Australia. It lies 335 km (208 mi) '+'south west of the nearest large town, Alice Springs; 450 km '+'(280 mi) by road. Kata Tjuta and Uluru are the two major '+'features of the Uluru - Kata Tjuta National Park. Uluru is '+'sacred to the Pitjantjatjara and Yankunytjatjara, the '+'Aboriginal people of the area. It has many springs, waterholes, '+'rock caves and ancient paintings. Uluru is listed as a World '+'Heritage Site.</p>'+'<p>Attribution: Uluru, <a href="http://en.wikipedia.org/w/index.php?title=Uluru&oldid=297882194">'+'http://en.wikipedia.org/w/index.php?title=Uluru</a> '+'(last visited June 22, 2009).</p>'+'</div>'+'</div>';var infowindow = new google.maps.InfoWindow({content: contentString});google.maps.event.addDomListener(marker, 'click', function() {infowindow.open(map,marker);});}google.maps.event.addDomListener(window, 'load', initialize);</script>
You need a helper function to create your markers, like the
createMarker() function in Larry's example* at
http://www.geocodezip.com/v3_MW_example_map1.html
If the data is kept together with a marker in a function, closure
ensures it's kept together.
Andrew
*reworked from Mike Williams' V2 example