maps - How to add info window for custom overlays? -


i have implemented custom overlay. want add event pop info window when click overlay.

function initmap() {   var map = new google.maps.map(document.getelementbyid('okmap'), {     zoom: 4,     center: {lat: 35.0000, lng: 103.0000}   });    (var n in nodes) {       var mymarker = new mymarker(map, {latlng: new google.maps.latlng(nodes[n][0], nodes[n][1]),                                      image: 'assets/img/light-green.png',                                     labeltext: (math.random() * 100).tofixed(0)});       markers.push(mymarker);       var infowindow = new google.maps.infowindow({           content: n       });       mymarker.addlistener('click', function() {           infowindow.open(map, mymarker);       });   } } 

but not working!

i faced simliar problem time back. here 2 things helped me. considering main overlay element div.

in mymarker.draw function make sure using pane has access dom events.e.g.

    var panes = this.getpanes();     panes.overlaymousetarget.appendchild(div); 

see https://developers.google.com/maps/documentation/javascript/customoverlays#initialize more details.

make sure define event listener, in mymarker.draw function.

google.maps.event.adddomlistener(div, "click", function(event) {     google.maps.event.trigger(self, "click"); }); 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -