
Untitled
By: a guest on
Aug 4th, 2011 | syntax:
HTML | size: 1.53 KB | hits: 59 | expires: Never
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<script type="text/javascript">
function initialize() {
var myLatlng = new google.maps.LatLng(30,0);
var myOptions = {
zoom: 2,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.TERRAIN
}
var map = new google.maps.Map(document.getElementById("map"), myOptions);
var countries = Array();
countries.push({
marker: new google.maps.Marker({position: new google.maps.LatLng(4.52,115), map: map, title: 'Test'}),
infowindow: new google.maps.InfoWindow({content: "Hello world"})
});
countries.push({
marker: new google.maps.Marker({position: new google.maps.LatLng(42.45,23.20), map: map, title: 'Test2'}),
infowindow: new google.maps.InfoWindow({content: "Hello world2"})
});
countries.push({
marker: new google.maps.Marker({position: new google.maps.LatLng(12.15,-1.30), map: map, title: 'Test3'}),
infowindow: new google.maps.InfoWindow({content: "Hello world3"})
});
for each (var item in countries) {
google.maps.event.addListener(item.marker, 'click', function() {
item.infowindow.open(map, item.marker);
});
}
}
</script>
</head>
<body onload="initialize();">
<div id="map" style="width:500px; height:500px; border:1px solid red;"></div>
<script type="text/javascript" src="http://maps.google.co.uk/maps/api/js?sensor=false"></script>
</body>
</html>