jquery - Google Maps External link for infowindow -


i've google maps setup, data coming mysql backend , i'm storing in encoded string. can display data in map properly, can't provide external link.

    (x = 0; x < stringarray.length; x = x + 1)     {         var addressdetails = [];         var marker;         //separate each field         addressdetails = stringarray[x].split("&&&");         //load lat, long data         var lat = new google.maps.latlng(addressdetails[1], addressdetails[2]);         //create new marker , info window         var y = x+1;         marker = new google.maps.marker({             map: map,             position: lat,             content: addressdetails[0],             icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld='+y+'|ff0000|000000'         });         //pushing markers array it's easier manage them         markersarray.push(marker);          google.maps.event.addlistener( marker, 'click', function () {             closeinfos();             var info = new google.maps.infowindow({content: this.content});             //on click map load info window             info.open(map,this);             infos[0]=info;         });        //extends boundaries of map include new location        bounds.extend(lat);     }     //takes lat, longs in bounds variable , autosizes map     map.fitbounds(bounds); 

and code external click.

    function myclick(i) {       google.maps.event.trigger(markersarray[i], "click");     } 

the error i'm getting is: "uncaught referenceerror: myclick not defined"

please guide i've gone wrong?

thanks,

given way you're trying call myclick, you'd need attach window object:

window.myclick = function(i) {     console.log('i defined , available in global scope via window!'); } 

here's demo.


Comments