1

In pset8, I have thought out 2 solutions for showing the information window when the user clicks on the marker.

 google.maps.event.addListener(marker, 'click', function() {
            showInfo(marker, articlesContent);

and

google.maps.event.addListener(marker, 'click', showInfo(marker, articlesContent);

why does the former work by the latter not work? I mean isn't showInfo also a function? why do you need to come up with another anonymous function and feed in the showInfo function?

Apologies if this a newbie kind of mistake but I am completely new to Javascript and have been struggling for days for this pset. Would appreciate if someone could help me out!

1

This google.maps.event.addListener(marker, 'click', showInfo(marker, articlesContent); is sending the result of the showInfo function.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .