Inside the google maps infowindow object I have called the showHotel() function but it did not gets called. When I just write alerert(”) is works but my own defined function did not work.
function showHotel(){
alert('Wapal po');
}
var infowindow = new google.maps.InfoWindow({
content: '<a href="#" onclick="showHotel()">Show Tasweer</a>'
});
You should globally declare
showHotel. If you add event listeners to a HTML string, the current scope is not respected. Your current code probably looks like:A method to leak the
showHotelmethod to the global scope is by prefixing the method bywindow.: