EJLD
Posts: 0
Joined: Sun Jun 08, 2014 11:03 pm

Create new infoWindow for multiple markers generated from REST.

Hi There, how you guys doing ?

when clicking on a googlemap marker, there is an infowindow popingup. that works well.
i wanted to insert a button in this infowindow.setContent.
the button appears well.
however, the function is not triggered. error msg is "invite4Game is not defined"

here after is my code, would you guys point out something wrong ?
thk you very much in advance

<!--
// call infowindows on click
google.maps.event.addListener(marker, 'click', (function(marker, j) {
...
infowindow.setContent('<div'+locations[j][0]+'<br<img src='+IdPicSrc+' style="width:100px;height:100px"<button onclick="invite4Game()"invite4Game</button<');
// infowindow position above the chosen marker
infowindow.open(map, marker);
},2500); // end of a setTimeout
};
})(marker, j));

Code: Select all

 var collector = locations[j][0]; 

 function invite4Game() { 
    some code ... ; 
 } 

} // end of listener function

--

Egor Kotov6832188
Posts: 0
Joined: Wed Nov 19, 2014 5:15 pm

Create new infoWindow for multiple markers generated from REST.

Hello EJLD,

invite4Game function is initialized in different scope for your onclick event, cause your google.maps.event.addListener added to the page as a separate global function in it's own context.

Solution: place invite4Game in same scope

EJLD
Posts: 0
Joined: Sun Jun 08, 2014 11:03 pm

Create new infoWindow for multiple markers generated from REST.

Hi Egor, thk you. I'll check this.

Return to “Issues”