I’ve been trying to show a GoogleMaps map, which is inside a fancybox div but, as it must be with display:none; from the beginning, once the map is loaded it’s partially displayed:
<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>
How can I use Fancybox to show the map, but having its associated div with display:none; from the beginning?
I’ve come across this issue a few times. The solution, in a nutshell, is not to pre-load the map but to load it after the container has become visible.
I think it’s because GMap can’t calculate the size it’s container if it’s hidden.