javascript - Adding an onclick event to an image inside a Google Maps InfoWindow -


i'm trying add onclick event image inside infowindow, when image clicked, javascript function called.

"name" name of place , "image" image location. both show fine when click on marker nothing happens when click on image.

my current code is:

var infowindow = new google.maps.infowindow({content: name + "</br>" + "<img onclick='output()' src='images/" + image +      "'style=height:100px;width:100px;float:none;>"});     google.maps.event.addlistener(marker, 'click', function() {     infowindow.open(map,marker);     });     function output()     {         $("#output").html("yes");     } 

and html:

<h1>my first google map</h1>  <div id="map" style="width:60%;height:500px"></div> <div id="output"></div>    </body> 

that's not answer, might can you, in topic show how trigger event on google maps trigger event infowindow or infobox on click google map api v3 :

   function addmarkers()     {         var marker, i;         var infowindow = new google.maps.infowindow({             disableautopan: true           ,ishidden:false           ,pixeloffset: new google.maps.size(-10, -10)           ,closeboxurl: ""           ,pane: "mappane"           ,enableeventpropagation: true         });         (var = 0; < citylist.length; i++)         {             marker = new google.maps.marker({                 position: new google.maps.latlng(citylist[i][1], citylist[i][2]),                 map: map,                 id: i,                 title: citylist[i][0]             });              var boxtext = document.createelement("div");             boxtext.id = i;             boxtext.classname = "labeltext" + i;             boxtext.innerhtml = citylist[i][0];             boxlist.push(boxtext);              google.maps.event.addlistener(marker, 'click', (function(marker, i) {                 var contentstring = '<div id="infowindow">'                     +'<div id="bodycontent">'                     +'<p>'                     + "this location is:<br>"                     + marker.title                     +'</p>'                     +'</div>'                     + '</div>';                  return function() {                     infowindow.setcontent(boxlist[this.id]);                     infowindow.open(map, marker);                 }                 })(marker, i)); //end add marker listener                  google.maps.event.adddomlistener(boxlist[i],'click',(function(marker, i) {                         return function() {                           alert('clicked ' + citylist[i][0])                         }                       })(marker, i));             } //endfor                       }//end function 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -