Skip to main content
+
Source Link
DinoCoderSaurus
  • 28.6k
  • 2
  • 12
  • 31

One problem is this syntax markers += marker;. That does not add an element to an array in js. The array method push adds elements to an array.

Another problem is here marker.addListener(map, "click", function(). That's not the correct syntax to add a listener to a marker (extraneous argument). Review the api doc here.

Once you get those things sorted, you'll run into trouble here showInfo(marker, data[i]);. data[i] is local to the addMarker function, so when it calls the function from the click action, there is no data[i] (read: it'smore specifically, there is no i, thus data[i] is undefined). You'll have to sort out what argument to send to showInfo.

Some hints for the content argument to showInfo:

From the spec (showInfo):

This function opens the info window at a particular marker with particular content (i.e., HTML).

From the spec (addMarker):

the contents of which should be an unordered list of links to article for that article’s location

Putting those two bits together, think about content as the HTML for an unordered list of links.

One problem is this syntax markers += marker;. That does not add an element to an array in js. The array method push adds elements to an array.

Another problem is here marker.addListener(map, "click", function(). That's not the correct syntax to add a listener to a marker (extraneous argument). Review the api doc here.

Once you get those things sorted, you'll run into trouble here showInfo(marker, data[i]);. data[i] is local to the addMarker function, so when it calls the function from the click action, there is no data[i] (read: it's undefined). You'll have to sort out what argument to send to showInfo.

One problem is this syntax markers += marker;. That does not add an element to an array in js. The array method push adds elements to an array.

Another problem is here marker.addListener(map, "click", function(). That's not the correct syntax to add a listener to a marker (extraneous argument). Review the api doc here.

Once you get those things sorted, you'll run into trouble here showInfo(marker, data[i]);. data[i] is local to the addMarker function, so when it calls the function from the click action, there is no data[i] (more specifically, there is no i, thus data[i] is undefined). You'll have to sort out what argument to send to showInfo.

Some hints for the content argument to showInfo:

From the spec (showInfo):

This function opens the info window at a particular marker with particular content (i.e., HTML).

From the spec (addMarker):

the contents of which should be an unordered list of links to article for that article’s location

Putting those two bits together, think about content as the HTML for an unordered list of links.

Source Link
DinoCoderSaurus
  • 28.6k
  • 2
  • 12
  • 31

One problem is this syntax markers += marker;. That does not add an element to an array in js. The array method push adds elements to an array.

Another problem is here marker.addListener(map, "click", function(). That's not the correct syntax to add a listener to a marker (extraneous argument). Review the api doc here.

Once you get those things sorted, you'll run into trouble here showInfo(marker, data[i]);. data[i] is local to the addMarker function, so when it calls the function from the click action, there is no data[i] (read: it's undefined). You'll have to sort out what argument to send to showInfo.