javascript - Google Maps Marker Clusterer: Nested Click Handling -


after hacking away dom , event propagation issues day i've come last of issues i've been trying deal using marker clusterer.

currently i'm attaching click handler dom element change state single infobox using code.

//google infobox plug in var boxtext = document.createelement("div"); boxtext.style.csstext = "border: 1px solid #e0e0e0; margin-top: 8px; background: white; padding: 5px; border-radius: 7px;"; boxtext.innerhtml = contentstring;      //when infowindow clicked, open view... google.maps.event.adddomlistener(boxtext, 'click', (function (marker) {   return function () {     $state.go("comments", {       "shoutid": activeid     });   } })(marker)); 

this works fine expected single info box window. when call getmarkers on cluster , same thing results not same.

in getmarker function i'm using loop iterate through cluster , append infobox looped content inside of it. apply boxtext event handler whole window wouldn't give me event handler on each individual marker section..

this code i'm using inside of marker cluster click event handler

 google.maps.event.addlistener(mc, 'click', function (cluster, $event) {      var content = '';     var clickedmarkers = cluster.getmarkers();     var splitterbar = "border-bottom";      (var = 0; < clickedmarkers.length; i++) {       if (i === 0) {         var var_pos = clickedmarkers[i];       }         var clickedmarkersnames = clickedmarkers[i].title;        var innertext = document.createelement("div");        //format shout body       content += '<div id="content " class="' + splitterbar + '">' +         '<div id="bodycontent">' +          '<article id="shout' + + '"class="">' +         '<p> ' +         clickedmarkers[i].title +         '</p>' +         '<a data-ui-sref="comments">' +         '<small class="grey">' + clickedmarkers[i].address + ' &#8226; ' +         moment.duration(date.now() - clickedmarkers[i].time).humanize() + ' &#8226; ' +         clickedmarkers[i].decibels + ' db &#8226; ' +         clickedmarkers[i].echoes + echoesplural +         '</small>' +         '</a>' +         '</article>' +          '</div>' +         '</div>';        //when infowindow clicked, open view...       google.maps.event.adddomlistener(innertext, 'click', (function () {         return function () {           alert("click");         }       })());      }      var boxtext = document.createelement("div");     boxtext.style.csstext = "border: 1px solid #e0e0e0; margin-top: 8px; background: white; padding: 0px; border-radius: 7px; max-height: 325px; overflow-y: auto;";     boxtext.setattribute("class", "animated fade");     boxtext.innerhtml = content;      var myoptions = {       content: boxtext,       disableautopan: false,       maxwidth: 0,       pixeloffset: new google.maps.size(-135, -40),       zindex: null,       boxstyle: {         background: "",         opacity: 1,         width: "280px"       },       closeboxmargin: "13px 5px 5px 5px",       closeboxurl: "",       infoboxclearance: new google.maps.size(1, 1),       ishidden: false,       alignbottom: true,       pane: "floatpane",       enableeventpropagation: false     };      var ib1 = new infobox(myoptions);       if (previousinfowindow) {       previousinfowindow.close();     }     previousinfowindow = ib1;       ib1.open(map, var_pos);    }); 

edit: added full marker click cluster feel attachment has done inside loop or else scope wouldn't correct.

i've done alot of reading on sparse amount of info related clusterer feel it's simple problem , i'd love insight else. help!

after bit of hacking. don't know if it's possible attach domlisteners in way. solve it. since couldn't use angular syntax inside of html box infobox. each marker cluster made element content. styled block , hid link elements make normal. manually pointed href view trying navigate , used id property had saved complete route. work's inside ionic it's rough hack. wanted post how managed around though else may looking.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -