Callback method for opening Google Maps InfoWindow -


i using google maps v3 , have markers on map show infowindow when clicked. infowindow needs contain image carousel. in order me initialize carousel, need run javascript after infowindow has opened. in effect need callback infowindow.open() method.

however unable find 1 have had resort using settimeout wait 1 second before initializing image carousel. not ideal.

does know of better way?

updated full code

var widgetmap; var widgetinfowindow; var widgetmarkers = []; var popindex = 0; var poptotal = 0;  $(document).ready(function () {     $.ajax({         url: '/handlers/googlelocations.ashx?kmlpath=<%= kmlpath %>',         datatype: "json",         success: function (data) {             cleardata();             initialize();             loadwidgetmapdata(data);         }     }); });  function initialize() {      var mylatlng = new google.maps.latlng(53.32, -7.71);     var mapoptions = {         zoom: 7,         center: mylatlng     };      widgetmap = new google.maps.map(document.getelementbyid('map-canvas'),         mapoptions);      widgetinfowindow = new google.maps.infowindow();     widgetinfowindow = new infobubble({         maxheight: 275,         maxwidth: 350,         arrowsize: 30,         arrowstyle: 2,         borderradius: 0,         disableautopan: false     });      google.maps.event.addlistener(widgetinfowindow, 'domready', initpopupcarousel); }  google.maps.event.adddomlistener(window, 'load', initialize);  function loadwidgetmapdata(data) {      var marker, i, image;      (i = 0; < data.locations.length; i++) {         var location = data.locations[i];         if (location) {              var pincolor = location.colour;             var image = new google.maps.markerimage("http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%e2%80%a2|" + pincolor,                 new google.maps.size(21, 34),                 new google.maps.point(0, 0),                 new google.maps.point(10, 34));              marker = new google.maps.marker({                 bubble: location.bubble,                 position: new google.maps.latlng(location.latitude, location.longitude),                 map: widgetmap,                 icon: image             });              google.maps.event.addlistener(marker, 'click', (function (marker, i) {                 return function () {                      widgetinfowindow.setcontent(data.locations[i].bubble);                     widgetinfowindow.open(widgetmap, marker);                  };             })(marker, i));              widgetmarkers.push(marker);         }     } }  function cleardata() {     widgetmap = null;     widgetinfowindow = null;     clearoverlays(); }  function clearoverlays() {     (var = 0; < widgetmarkers.length; i++) {         widgetmarkers[i].setmap(null);     }     widgetmarkers = []; }  function initpopupcarousel() {     alert("here"); } 

update details loading kml web service there filtering of map markers taking place elsewhere.

the current behavior code click marker, alert shows , infobubble opens. appears "domready" occurs before infobubble rendered.

use 'domready' event of infowindow

google.maps.event.addlistener(marker, 'click', (function (marker, i) {    return function () {        widgetinfowindow.setcontent(data.locations[i].bubble);        widgetinfowindow.open(widgetmap, marker);        google.maps.event.addlistener(widgetinfowindow,'domready',initpopupcarousel);    }; })(marker, i)); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -