Trying to create a custom google map, I wrote the code, but something was wrong, I thought if anyone could indicate what I did wrong. The code is here:
<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_canvas"), 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); }); }
source share