Fairly new to Google Maps API. I’ve got an array of data that I want to cycle through and plot on a map. Seems fairly simple, but all the multi-marker tutorials I have found are quite complex.
Let’s use the data array from Google’s site for an example:
var locations = [
['Bondi Beach', -33.890542, 151.274856, 4],
['Coogee Beach', -33.923036, 151.259052, 5],
['Cronulla Beach', -34.028249, 151.157507, 3],
['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
['Maroubra Beach', -33.950198, 151.259302, 1]
];
I simply want to plot all of these points and have an `infoWindow` pop up when clicked to display the name.
This is the simplest I could reduce it to:
SCREENSHOT
There is some closure magic happening when passing the callback argument to the
addListenermethod. This can be quite a tricky topic if you are not familiar with how closures work. I would suggest checking out the following Mozilla article for a brief introduction if it is the case:❯ Mozilla Dev Center: Working with Closures