I am going to need at least 3 maps on the same page (one below the other, not side by side), each containing multiple markers. Can anyone tell me how to get three versions of this on the same page (after which I can amend the details for each one)? I'm basically feeling my way here, not knowing much about javascript.
Many thanks in advance - Roger
<div id="map" style="height:400px;width:541px;display:block;">
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">
</script>
<script type="text/javascript">
function mapIt(){
var latlng = new google.maps.LatLng(24.00, 0.00);
var myOptions = {
zoom: 1,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
}
var map = new google.maps.Map(document.getElementById('map'), myOptions);
setMarkers(map, places);
}
var places = [
['London',51.50, -0.125,"Markers/green.png"],
['Abidjan',5.34, -4.03,"Markers/red2.png"],
['Abu Dhabi',24.47, 54.37,"Markers/red2.png"],
];
var popUps = [
'<strong>London</strong><br />link to larger map',
'<strong>Abidjan, Ivory Coast</strong><br />Content here',
'<strong>Abu Dhabi, United Arab Emirates</strong><br />Content here>',
]
var infowindow;
function setMarkers(map, locations) {
for (var i = 0; i < places.length; i++) {
var myLatLng = new google.maps.LatLng(locations[i][1], locations[i][2]);
var icon = locations[i][3];
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: locations[i][0],
icon: icon
});
(function(i, marker) {
google.maps.event.addListener(marker,'click',function() {
if (!infowindow) {
infowindow = new google.maps.InfoWindow();
}
infowindow.setContent(popUps[i]);
infowindow.open(map, marker);
});
})(i, marker);
}
};
mapIt();
</script></div>