0
I have two maps on one page, I am using slideToggle and slideup to display make available for viewing only one map at a time. mapa_fixed and mapa_movement are the Ivs that contain the maps.
#mapa_fixo
{
    display:none;
}
#mapa_movimento
{
    display:none;
}
    function verifica_categoria_carrega_mapa(id)
    {
    var id_categoria = id;
    if(id==1)
    {
        if($("#mapa_fixo").is(":visible") == true)
        {
        }
        else
        {
            $("#mapa_fixo").slideToggle();
            $("#mapa_movimento").slideUp();
            return false;
        }
    }
    else if(id==2)
    {
        if($("#mapa_movimento").is(":visible") == true)
        {
        }
        else
        {
            $("#mapa_fixo").slideUp();
            $("#mapa_movimento").slideToggle();
            gmaps.refresh()
            return false;
        }
    }
}
It’s working, but, the maps are not being displayed correctly, due to jquery components one of the maps is loaded into a file. js the other directly on the page.
If loading the maps normally, without having Display:None, the maps normally load.


Are you using any external plugin to do this? The initial toggle state is closed?
– celsomtrindade
For Toggle I am not using any plugin, initially I only set Divs as display:None, not referencing toggle. If you have another way to do this, even without using the toggle, it will be great.
– sNniffer
Well, I had a similar problem, but in Angularjs (the code was a little different, I don’t know how to adapt to your model). The problem occurred because the map div started as
display:nonealso. What I had to do was apply the map reset, which happens in the DOM load.– celsomtrindade
I started using the
google.maps.event.addDomListener(window, 'load', initialize);, but, unsuccessfully, I saw something related togoogle.maps.event.addListenerOnce(map_rota, 'idle', function(), but, I did not find method to execute, knows something?– sNniffer