I recently encountered a frustrating issue that plagued me for several days, but today I finally discovered the solution and it resolved the problem!
In my particular situation, I utilized tabs to navigate different sections of my webpage. Rather than using jquery ui, I custom-built these tabs myself. Within one tab, I inserted the code for a map display. However, upon clicking the maps tab, I was met with a broken map. After some investigation, I identified both the issue at hand and the remedy.
To toggle the visibility of my elements, I previously employed the display:none
property to hide them and display:block
to reveal them. The problem arose when the Google map attempted to determine the dimensions of the hidden container, resulting in 0 x 0
, thus displaying the broken map.
To rectify this, I adjusted the CSS specifically for the map tab by setting it to position:absolute;left:-99999px;
instead of utilizing
display:none</code. Additionally, I implemented <code>jquery
to dynamically add or remove a class as needed, incorporating the aforementioned properties. This modification successfully resolved the issue, restoring functionality to my map display.