简体   繁体   English

在悬停地图标记上打开Gmap信息窗口

[英]Open Gmap Info Window on hover Map Marker

Currently the info window is opening when user clicks the marker on PrimeFaces GMap component . 当前,当用户单击PrimeFaces GMap组件上的标记时,信息窗口正在打开。 How can I customize it to open up the info window when user hovers the marker? 当用户悬停标记时,如何自定义它以打开信息窗口?

Answered: 回答:
Thanks zargarf. 谢谢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 我设法使用一些附加的JavaScript来删除onclick监听器,然后添加一个鼠标悬停监听器

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM