谷歌地图infowindow无法在fancybox中正确显示

时间:2013-07-15 10:51:50

标签: jquery google-maps-api-3 fancybox

我已经让google地图在fancybox窗口中运行得很好。但是,infowindow显示不正确,请注意指向标记的箭头丢失,关闭它的X丢失,背影不正确。可以点击X(我猜它隐藏在后台)

下面是为我显示的图像

Valid XHTML http://www.tappertracker.com/ScreenShot2013-07-15.png

构建此功能的功能如下:

    if (response["resp"].length > 0) {

        frLocations = new Array();
        for ( var i = 0; i < response["resp"].length; i++) {
            var elements = new Array();

            elements[0] = response["resp"][i]["summary"];
            elements[1] =  response["resp"][i]["latitude"];
            elements[2] =  response["resp"][i]["longtitude"];
            elements[3] =  i + 1;
            elements[4] = "<h4>" + response["resp"][i]["summary"] + "</h4><p><i>" + response["resp"][i]["description"] + 
                "</i></p><p>Starting: " + String.createStringFromMysqlDateFormat(response["resp"][i]["startDate"]) + "</p>"+ 
                "<p>Ending: " + String.createStringFromMysqlDateFormat(response["resp"][i]["endDate"]) + "</p>";
            frLocations[i] = elements;                  
        }           
    }

    var map = new google.maps.Map(document.getElementById('map'), {
        zoom : 11,
        center : new google.maps.LatLng(response["ha"]["lat"], response["ha"]["long"]),
        mapTypeId : google.maps.MapTypeId.ROADMAP
    });
    if (response["resp"].length > 0) {
        var infowindow = new google.maps.InfoWindow();

        var marker, i;

        for( i = 0; i < frLocations.length; i++) {
            marker = new google.maps.Marker({
                position : new google.maps.LatLng(frLocations[i][1], frLocations[i][2]),
                map : map,
                title : frLocations[i][0]
            });

            google.maps.event.addListener(marker, 'click', (function(marker, i) {
                return function() {
                    infowindow.setContent(frLocations[i][4] );
                    infowindow.open(map, marker);
                }
            })(marker, i));
        }           
    }

编辑: 附加启动弹出窗口的精美盒子代码是

$("#fr-map").click(function(){
            $.fancybox({
                'href': '#fr_div',
                'afterShow': function() { 
                    getFundraisersNearMe(showFundRaisers);}
            });
            return false;
        });

html

<div id="mapFormDiv" style="display:none">
    <div id="fr_div">
<h1>Fundraisers in your area</h1>
<div id="map" style="width: 500px; height: 400px;"></div>
</div>

1 个答案:

答案 0 :(得分:0)

我有完全相同的问题。这与干扰谷歌的bootstrap样式有关。我用

解决了我的问题
/** FIX for Bootstrap and Google Maps Info window styes problem **/
img[src*="gstatic.com/"], img[src*="googleapis.com/"] {
max-width: none;
}

或只是

img {
 max-width: none;
}