谷歌地图 - 在点击事件或之后修改infowindow css

时间:2015-01-09 20:38:45

标签: google-maps events infowindow

在Google地图上,我想在显示Infowindow之前调整InfoWindow的初始布局。具体来说,我想在单击eventL

之后或之后执行此操作
            // on click             
            $(".tabs").hide();
            $("#summary").show();

这是在单击标记时(成功)创建信息窗口的代码。我需要找到上面添加上面代码和事件的位置。

        // Renders the marker on the specified map
        marker.setMap(map); 

        // create an InfoWindow
        var infoWnd = new google.maps.InfoWindow();         

        // add content to your InfoWindow
        infoWnd.setContent('<div class="scrollFix">' + infoWindowContent);

        // add listener on InfoWindow - close last infoWindow  before opening new one 
        google.maps.event.addListener(marker, 'click', function() {

            //Close active window if exists 
            if(activeInfoWindow != null) activeInfoWindow.close();

            // Open InfoWindow
            infoWnd.open(map, marker);

            // Store new open InfoWindow in global variable
            activeInfoWindow = infoWnd;

            ....

1 个答案:

答案 0 :(得分:0)

尝试在InfoWindow上设置监听器&#39; domready&#39;事件。触发后,将更改应用于InfoWindow的内容。

        // Renders the marker on the specified map
        marker.setMap(map); 

        // create an InfoWindow
        var infoWnd = new google.maps.InfoWindow();         

        // put a listener of InfoWindow, when "domready", make changes to content
        google.maps.event.addListener(infoWnd, 'domready', function() {
            $("span.tabs").hide();
            $("#summary_tab").show();                       
        });

        // add content to your InfoWindow
        infoWnd.setContent('<div class="scrollFix">' + infoWindowContent + "<div>");


        // add listener on InfoWindow for CLICK event- close last infoWindow  before opening new one 
        google.maps.event.addListener(marker, 'click', function() {


            //Close active window if exists
            if(activeInfoWindow != null) activeInfoWindow.close();

            // Store new open InfoWindow in global variable
            activeInfoWindow = infoWnd;

            // Open InfoWindow
            infoWnd.open(map, marker);              
        });