click event listener on styled map icons and labels -


is possible add listener click event on icons and/or labels appear styled maps? have form allows entry of points of interest. since poi styling shows icons and/or labels many potential candidates, , clicking on 1 opens infowindow address info, etc, capture address info fields on form if user clicks on one.

there no api-based access poi's .

but there possible workaround.

when click on poi infowindow opens. it's possible modify infowindow-prototype able access content of infowindow without having reference infowindow-instance.

      //store original setcontent-function       var fx = google.maps.infowindow.prototype.setcontent;        //override built-in setcontent-method       google.maps.infowindow.prototype.setcontent = function (content) {           //when argument node           if (content.queryselector) {               //search address               var addr = content.queryselector('.gm-basicinfo .gm-addr');               if (addr) {                    alert(addr.textcontent);                   //leave function here                    //when don't want infowindow appear                }           }           //run original setcontent-method           fx.apply(this, arguments);       }; 

demo: http://jsfiddle.net/doktormolle/vkf43/

note: selectors infowindow not documented, may change in future


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -