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 Google Maps Integration Adding Point Markers to a Map: Markers

In app.js, on line 20, initialize a new marker with the 'map' set to 'theMap' and the 'position' set to 'addressLocation

Can anyone see why the code below does not work?

var marker = new google.maps.Marker({map: theMap, position: addressLocation});


Bummer! The marker wasn't initialized properly. Try using '{map: theMap, position: addressLocation}' in to a 'new google.maps.Marker'

3 Answers

I just passed it with this line:

var marker = new google.maps.Marker({map: theMap, position: addressLocation});

I can't see any difference between the two. Maybe try again in case the code challenge was having some problems.

Maybe try copying my code here and pasting that into the code challenge.

Hey thanks a lot! The problem, it turns out, was that I was creating this variable inside the script tag on the HTML as opposed to on the app.js file (very dumb mistake I know). In fact, there is nothing wrong with the code above!

That makes sense. Glad you figured it out.