Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

PROBLEM SOLVED: Customizing Google Maps > Adding Info Windows

For some reason, Step 2/3 keeps prompting me to do exactly this, even though I've done it. I guess forward this to the development team, because I can't figure out what's wrong here. Here's the code challenge: http://teamtreehouse.com/library/adding-info-windows

google.maps.event.addListener(marker, "click", function(){});

4 Answers

James Barnett
James Barnett
39,199 Points

@John - Rock on with your bad self :guitar:

I was adding this below the original var declaration of infoWindow, not further down where it needed to be.

Not solved for me, I get the error "You need to call 'google.maps.event.addListener()' with 'marker', 'click' and an anonymous function."

This the last 13 lines

geocoder.geocode(
geocoderOptions,
function(results, status) {
    if(status == google.maps.GeocoderStatus.OK) {
        var marker = new google.maps.Marker({map: theMap, position: results[0].geometry.location});
        markers.push(marker);
        bounds.extend(results[0].geometry.location);
        theMap.fitBounds(bounds);
                    infoWindow = new google.maps.InfoWindow({content: "Magic Kingdom"});
            }
}
);
google.maps.event.addListener(marker, "click", function(){});

ah ok, solved, misunderstood the question.

geocoder.geocode(
geocoderOptions,
function(results, status) {
    if(status == google.maps.GeocoderStatus.OK) {
        var marker = new google.maps.Marker({map: theMap, position: results[0].geometry.location});
        markers.push(marker);
        bounds.extend(results[0].geometry.location);
        theMap.fitBounds(bounds);
                    infoWindow = new google.maps.InfoWindow({content: "Magic Kingdom"});

    }
            google.maps.event.addListener(marker, "click", function(){});
}
)