marker2 is not defined until the callback function is fired. Since the geocoder works asynchronously, it will not be available for the next line of code in the initial block. Move your infowindow and event.addListener calls into the callback function that you pass the geocoder.
Jeremy R. Geerdes Generally Cool Guy Des Moines, IA For more information or a project quote: [email protected] If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan Church! On Nov 10, 2011, at 5:54 AM, Danilo Giaretta wrote: > new geocoder.geocode( { 'address': address}, function(results, > status) { > var marker2 = new google.maps.Marker({map: map, //Criar o > Marcador > position: results[0].geometry.location, > title:'Teste', > icon:teste}); > }); > > var infowindow = new google.maps.InfoWindow({ > content: texto > }); > > google.maps.event.addListener(marker2, 'click', function() { > infowindow.open(map,marker2); > }); > > Why that dont work? > i want create a marker with data of datebase. But on load, that dont > work and say 'marker2 is not defined'. > > anyone know? > thanks > > - > > Por que isso não funciona? > Eu quero criar os marker com meus dados vindo do banco de dados. > Porem não funciona, ele criar os marker mas não consegue associar o > infowindow nele. > > Obrigado. > > -- > 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. > -- 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.
