Finishing up pset8 and I'm having difficulties understanding exactly what is required (the instructions I find to be quite unclear particularly re addmarker).

I assume that addmarker is to display markers on the map (which I have done) with labels and custom icon. I haven't been able to implement showinfo however and I think it is because I am not sure what functionality is required. Does addmarker have to pass the output from articles.php to showinfo? if so, I'd love some advice on the syntax for the listener event and/or showinfo call.

1 Answer 1


I'm not sure where exactly you added the markers in your code, but I find the instructions clear about what addMarker is supposed to do.

Implement addMarker in scripts.js in such a way that it adds a marker for place on the map, where place is a JavaScript object that represents a row from places, your MySQL table.

see addMarker for more!

so if you were able to write code that adds markers to the map and customize them, that's great except that you want addMarker to be the method that is responsible for adding a marker that represents a single place on the map then use it to add all the markers you want (one by one).

Does addMarker have to pass the output from articles.php to showInfo?

not exactly! add marker should make each marker it adds listen for mouse clicks such that if a marker is clicked, showInfo is called with the appropriate arguments in order to show a window containing a spinning icon, an unordered list of articles, or maybe an info message in case there are no articles to show for this location.

see showInfo for more!

I'd love some advice on the syntax for the listener event and/or showInfo call.

if I have a marker called marker, I may listen for clicks on it as follows:

marker.addListener('click', function() {
    // do something

see Events for more info!

  • thanks Kareem, I get all of that, and I have tried adding code the same as your suggestion. Its the //do something I am having trouble with, do I need to pass the output from articles.php to showinfo in that section of the code? Commented Dec 21, 2015 at 8:35
  • @LisaSmith articles.php returns a JSON string of the articles found (if any). you should parse this JSON string as JSON, process it, and build according HTML structure into a string, then pass it as the second argument to showInfo. if you're using plain JavaScript, JSON.parse may help! if you're using jQuery, parseJSON() may help!
    – kzidane
    Commented Dec 21, 2015 at 8:49
  • that's what I needed, I just needed confirmation I was on the right track, thanks Kareem! Commented Dec 21, 2015 at 8:53
  • PS I may finish by the end of the year at this rate!!! Commented Dec 21, 2015 at 8:54
  • @LuluMachete keep going! all the best!
    – kzidane
    Commented Dec 21, 2015 at 9:03

You must log in to answer this question.

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