除非我打开/关闭萤火虫,否则不会加载OpenLayers中的某些图块

时间:2012-10-18 11:12:00

标签: firebug openlayers openstreetmap firebug-lite

我想将地图加载到灯箱中。因此,一旦触发链接,就会显示包含地图的灯箱。 但是当我这样做时,一些瓷砖没有加载,除非我打开/关闭萤火虫(取决于它是否已经打开) 实际上不仅是firebug,还有Chrome检查员和IE开发人员工具。 我在一个页面(没有灯箱)上单独尝试它具有相同的大小和相同的结构,一切都工作正常。 顺便说一句,我正在使用OpenLayers-2.12。 这是调试中的问题还是什么?如果是的话,我该如何解决?

这是所有页面的代码:

<html>
<head>
        <script type="text/javascript" src="/js/jquery-1.7.min.js"></script>
        <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
        <script type="text/javascript">

            function longlat(lon,lat) {
                var fromProjection = new OpenLayers.Projection("EPSG:4326");
                var toProjection   = new OpenLayers.Projection("EPSG:900913");
                return new OpenLayers.LonLat(lon,lat).transform(fromProjection, toProjection);
            }

             function init_map() {
                var map = new OpenLayers.Map("basicMap");
                var mapnik         = new OpenLayers.Layer.OSM();
                var position       = longlat(28.8013,31.1711);
                var zoom           = 3; 
                var markers = new OpenLayers.Layer.Markers( "Markers" );
                map.addLayer(markers);
                var size = new OpenLayers.Size(21,25);
                var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
                var icon = new OpenLayers.Icon('http://www.openlayers.org/dev/img/marker.png', size, offset);

                var location = new OpenLayers.Geometry.Point(28.8013, 31.1711).transform('EPSG:4326', 'EPSG:3857');

                var popup = new OpenLayers.Popup.FramedCloud('Popup',location.getBounds().getCenterLonLat(),new OpenLayers.Size(200,200),'<p>some text</p>',null,true);
                var marker = new OpenLayers.Marker(longlat(28.8013,31.1711),icon.clone());
                   marker.events.register('click',marker,function (evt) { 
                        map.addPopup(popup);
                        popup.show(); 
                   });
                   markers.addMarker(marker);


                    map.addLayer(mapnik);
                    map.setCenter(position, zoom);


              }

             </script>



        <script type="text/javascript">
                    jQuery(document).ready(function() {
                        init_map();
                        jQuery('#map_button').click(function() {
                            jQuery('.map_lightbox , .map_box , #basicMap').css('display','block');
                            jQuery('.map_lightbox').animate({opacity:0.8},300,'linear');
                            jQuery('.map_box').animate({opacity:1.0},500,'linear');

                            jQuery('.map_close').click(function() {
                                map_close();
                            });

                            jQuery('.map_lightbox').click(function() {
                                map_close();
                            });

                        });


                    });



                    function map_close() {
                        $('.map_container').children('object').remove();
                        $('.map_lightbox').animate({opacity:0},300,'linear',function() {
                            $('.map_lightbox , .map_box').css('display','none');
                        });
                    }
        </script>

        <style>
            .map_lightbox {
                    position: fixed;
                    top:0px;
                    left:0px;
                    width:100%;
                    height:100%;
                    background:#000000;
                    opacity:0;
                    filter:alpha(opacity=0);
                    z-index: 1000;
                    display:none;
                }

                .map_box {
                    position:fixed;
                    top:20%;
                    left:25%;
                    width:600px;
                    height:400px;
                    background :#f2f2f2;
                    z-index:1005;
                    padding:10px;
                    -moz-border-radius: 5px;
                    -webkit-border-radius: 5px;
                    border-radius:5px;
                    display:none;
                }

                .map_close {
                    cursor:pointer;
                    float:right;
                    margin-left:98%;
                    font-weight:bold;
                }

                .map_container {
                    margin-right:5px;
                }

                .map_container {
                    width:95%;
                    height:95%;
                    position:relative;
                    float:right;
                    margin-right:20px;
                    -moz-border-radius:3px;
                    border-radius:3px;
                    -webkit-border-radius:3px;
                }
        </style>
</head>
<body>
    <div class='map_lightbox'>
    </div>
    <div class='map_box'>
        <div class='map_close'>x</div>  
        <div class='map_container'>
            <div id='basicMap' style='width:100%;height:100%;display:none;position:absolute;'></div>
        </div>
    </div>
    <a href='javascript:void(0)' id='map_button' >full map</a>
</body>
</html>

感谢

1 个答案:

答案 0 :(得分:0)

这会对最终结果产生任何影响吗?

   OpenLayers.IMAGE_RELOAD_ATTEMPTS = 5;

另外,javacript调试器在某处“破解”了吗?可能是由于js错误?最后,你的'net'面板是否显示任何非http响应代码200行(通常为红色)。然后你知道电话已经通过但是失败了。