Salve sto cercando di creare una mappa con dei markers partendo da degli indirizzi
ma ho un problema su tutti i marker che creo mi riporta come tag lo stesso .. ovvero l'ultima descrizione che ho caricato nell'array e non capisco il motivo ?!
vi riporto sotto lo script
	
	
	
		
				
			ma ho un problema su tutti i marker che creo mi riporta come tag lo stesso .. ovvero l'ultima descrizione che ho caricato nell'array e non capisco il motivo ?!
vi riporto sotto lo script
		HTML:
	
	<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps JavaScript API v3 Example: Geocoding Simple</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
  var geocoder;
  var map;
  var tag =""; 
  var address ="";
  var indirizzo = [ 'San Diego, CA', 'Firenze, Italia','Cortona, Italia','Perugia, Italia','Roma, Italia'		];
  var descrizione = [ '1111', '222222','333333','444444','55555'		];  
  function initialize() {
    geocoder = new google.maps.Geocoder();
    var latlng = new google.maps.LatLng(-34.397, 150.644);
    var myOptions = {
      zoom: 8,
      center: latlng,
    mapTypeControl: true,
    mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
    navigationControl: true,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    for (var i = 0; i < indirizzo.length; i++) { 		address=indirizzo[i];       tag = descrizione[i];
      geocoder.geocode( { 'address': address}, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
          if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
          map.setCenter(results[0].geometry.location);
            var infowindow = new google.maps.InfoWindow(
                { content: '<b>'+tag+'</b>',
                  size: new google.maps.Size(150,50)
                });
    
            var marker = new google.maps.Marker({
                position: results[0].geometry.location,
                map: map, 
                title:tag
            }); 
            google.maps.event.addListener(marker, 'click', function() {
                infowindow.open(map,marker);
            });
          } else {
            alert("No results found");
          }
        } else {
          alert("Geocode was not successful for the following reason: " + status);
        }
      });
    }
  }
</script>
</head>
<body style="margin:0px; padding:0px;" onload="initialize()">
 <div id="map_canvas" style="width:100%; height:100%">
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-162157-1";
urchinTracker();
</script>
</body>
</html>
	
			
				Ultima modifica di un moderatore: