使用Fancybox的Google地图

时间:2011-11-15 03:15:25

标签: google-maps cakephp fancybox

我一直试图展示一个GoogleMaps地图,它位于一个fancybox div中,但是必须使用display:none;从一开始,一旦加载了地图,就会部分显示:

    <div style="display:none;position:absolute;z-index:-999;top:45px;left:300px;" id="divMapCreate" name="divMapCreate">
        <div id="createItemDiv2" style="border:1px solid;width:450px;">
            <?php echo $this->Form->create(array('action'=>'create2', 'type' => 'post', 'id'=>'createItem2', 'name'=>'createItem2')); ?>
            <table border="0" width="100%" align="center" cellspacing="0">
                <tr>
                    <td align="center">
                        <strong>Creating an Item</strong>
                    </td>
                </tr>
                <tr>
                    <td align="center">
                        <div id="map_canvas_create" style="width: 450px; height: 350px"></div>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <?php echo $this->Form->end('DONE - CREATE'); ?>
                    </td>
                </tr>
            </table>
        </div>

如何使用Fancybox显示地图,但将其关联的div与display:none;从一开始?

1 个答案:

答案 0 :(得分:0)

我几次遇到过这个问题。简而言之,解决方案不是预先加载地图,而是在容器变得可见之后加载它。

我认为这是因为如果它被隐藏,GMap无法计算它的容器大小。