Question

I have a working google map using the JavaScript API v3, but I am getting a javascript error on a new function I added.

I'm working on a new function to make links outside the map that show the respective infowindow on its marker. It should work like this.

I have the new features commented in my code on this jsfiddle as // TESTING

In the console, clicking the links outside of the map throws the error:

Uncaught ReferenceError: htmlinfowindowclick is not defined

Here's my code:

JSFiddle

Thanks!

Was it helpful?

Solution

The htmlinfowindowclick function should be outside of the initialize function. Also var gmarkers = []; should be defined outside your functions so that it can be accessed by both functions.

var gmarkers = [];

function htmlinfowindowclick(item) {
    google.maps.event.trigger(gmarkers[item], 'click');
}

function initialize() {
    [...]
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top