问题描述:

Currently the info window is opening when user clicks the marker on PrimeFaces GMap component.

How can I customize it to open up the info window when user hovers the marker?

Answered:

Thanks zargarf. It worked.

网友答案:

I've managed to do it using a bit of additional javascript to remove the onclick listener and then add a mouseover listener

<script>
                //<![CDATA[
                $(document).ready(
                        function() {
                            var fullMap = myMap; //substitute myMap for the widgetVar name of your p:gmap component
                            var gmap = myMap.getMap();
                            var markers = gmap.markers;
                            for (i = 0; i < markers.length; i++) {
                                var v = google.maps.event;
                                google.maps.event
                                        .clearInstanceListeners(markers[i]);

                                google.maps.event.addListener(markers[i],
                                        'mouseover', function(event) {
                                            fullMap.fireOverlaySelectEvent(event,
                                                    this);
                                        });
                            }

                        });
                //]]>
            </script>
相关阅读:
Top