Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Build an Interactive Website Customizing Google Maps Adding Info Windows

Steve Leichman
Steve Leichman
7,008 Points

Code Issues on Adding Info Windows Code Challenge

Just an FYI, there are some issues with the questions on this challenge

For the first task, you're asked to:

On line 27, set the variable "infoWindow" to a "new google.maps.InfoWindow" passing in an object with the key "content" set to the string of "Magic Kingdom"

In the second task, the direction is:

On the next line, in app.js, use "google.maps.event.addListener()" with "marker" as the first argument, "click" as the second, and then an anonymous function as the third.

When I attempted the task on line 18 I was told I was incorrect. When I attempted the task on line 28, it passed.

Just FYI if this is driving anyone nuts.

1 Answer

Emily Martinez
Emily Martinez
13,096 Points

Re: the second task

Yes, this was driving me crazy, but it makes sense.

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

If you try to run the code above on line 18, it fails because there is no global variable "marker" to pass to the addListener method. "marker" is declared on line 23 inside the anonymous function inside the .geocode() method, which means you can only access it locally (i.e. on line 28).

Hope that helps clarify things.