Say if I have 3 layers with different table schemas (fields), I pushed all three layers into one array and loop through the array to add listeners to each layer so that everytime I click on the map, all three layers should be triggered the click event and I can proceed to get details of the event triggered such as featureId or InfoWindowHtml. Theoretically, problem should be solved, but it doesn't work. I assume that googlemaps api only fires the event that is bound to the top visible layer object.

Is there any way that I can trigger all three events at the same time manually on I click a place on map?

//Loop through each layer  
            for (var i = 0; i < visibleLayersNo; i++) {  

                var layer = this.options.visibleLayers[i];                 

                //Attach custom map click event to each layer,  
                 //but the event can only be fired when the object bound to it is on top and visible.  
                google.maps.event.addListener(layer, 'click', function(event){  
                    //do something  

You could fire the events yourself. It's covered in this post on Stack Overflow.

google.maps.event.trigger(layer, 'click', new google.maps.MouseEvent(...));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.