It looks like your "i" variable you use inside your for loop &
function is reserved or already used by the geocoder function, so it's
always set to 4, which is outside the bounds of your "descr" array.
Setting the variable name to anything else will make it work like you
want. Below is the relevant code:

        for (var i = 0; i < descr.length; i++) {
                var somethingelse = i;          // <--- This is where I change 
it from "i"
to something else, before it enters the function on the next line
                geocoder.geocode({ 'address': indirizzo[i]}, function(results,
status) {
                        map.setCenter(results[0].geometry.location);
                        var marker = new google.maps.Marker({
                                map: map,
                                position: results[0].geometry.location,
                                title: descr[somethingelse]
                        });
                });
        }



On Mar 6, 8:30 am, Cirdan il Timoniere <[email protected]>
wrote:
> Sorry if I have not follow the guidelines...
> These are the links concerning my problem:
>
> http://cirdan.ilbello.com/cirdanmaps/ex1.htm
>
> http://cirdan.ilbello.com/cirdanmaps/ex2.htm
>
> In ex1.htm I try to visualize the content of array descr[i] as tip of
> the marker (its location is included in the indirizzo[i] array). It
> does not work.
> In ex2.htm I use a fixed string. In this case the string is shown.
> What's wrong with my 'for' cycle.
> Thanx
>
> On 5 Mar, 16:13, Marcelo <[email protected]> wrote:
>
>
>
> > On Mar 5, 10:21 am, Cirdan il Timoniere
>
> > <[email protected]> wrote:
> > > Please see this code...
>
> > No, thanks.
> > Please see these posting guidelines:
>
> >http://groups.google.com/group/google-maps-js-api-v3/browse_thread/th......
>
> > --
> > Marcelo -http://maps.forum.nu
> > --
>
> > > <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></title>
> > > <script type="text/javascript" src="http://maps.google.com/maps/api/js?
> > > sensor=false&sfgdata=
> > > +sfgRmluamFuX1R5cGU9amF2YV9zY3JpcHQmRmluamFuX0xhbmc9dGV4dC9qYXZhc2NyaXB0+a"
> > >  ></
> > > script>
>
> > > <script type="text/javascript">
> > >   var geocoder;
> > >   var map;
> > >   function initialize() {
> > >     geocoder = new google.maps.Geocoder();
> > >     var opzioni = {
> > >       zoom: 8,
>
> > >             mapTypeId: google.maps.MapTypeId.ROADMAP
> > >     }
> > >     map = new google.maps.Map(document.getElementById("map_canvas"),
> > > opzioni);
>
> > > var indirizzo = new Array();
> > > var descr = new Array();
> > > indirizzo[0]="Milano, Italy";
> > > descr[0]='Milano';
> > > indirizzo[1]="Piacenza, Italy";
> > > descr[1]="Piacenza";
> > > indirizzo[2]="Brescia";
> > > descr[2]="Brescia";
> > > indirizzo[3]="Arcore, Italia";
> > > descr[3]="Arcore";
>
> > > var i = 0;
> > > for (i=0; i<4; i++)
>
> > > {
>
> > >        geocoder.geocode({ 'address': indirizzo[i]}, function(results,
> > > status) {
>
> > >           map.setCenter(results[0].geometry.location);
>
> > >               var marker = new google.maps.Marker({     map: map,
> > >                                             position: 
> > > results[0].geometry.location,
> > >                                            title: descr[i]        });
>
> > >                                      });
>
> > >                                                                           
> > >                          }
>
> > >   }
>
> > > </script>
> > > </head>
> > > <body style="margin:0px; padding:0px;" onload="initialize()">
> > >   <div>
>
> > >   </div>
> > > <div id="map_canvas" style="width:100%; height:90%"></div>
> > > </body>
> > > </html>
>
> > > I can't visualize the string included in the array named descr[i].
> > > If instead oftitle: descr[i],  i put a fixed string, so the code
> > > become
>
> > >      var marker = new google.maps.Marker({     map: map,
> > >                                             position: 
> > > results[0].geometry.location,
> > >                                            title: 'Hello World'           
> > > });
>
> > > thevisualizationworks!!! I'm, going mad. Could you help me please?
> > > Thanx

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to