Skip Navigation

[Resolved] Maps in Tabs (Ultimate Shortcode)

This support ticket is created 6 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 6 years, 11 months ago.

Assisted by: Nigel.

Author
Posts
#599853

Hello,

I feel that the map does not work well when it is in a tabs

Why ?

Thanks

#599920

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Christophe

I expect what you mean is that if the map is on the first tab (or whichever tab is "open" when the page loads) the map displays correctly, but when the map is on an initially-hidden tab then switching to that tab it appears that there is no map.

The problem is that the tab content is hidden initially, and—depending on how that is done—Google maps doesn't know how big to draw the map.

The solution is to re-draw the map when tabs are switched.

Try adding the following custom JS to where you insert the map in VC tabs:

( function( $ ) {
    $( document ).ready( function(){
  
        $('vc_tta-tab > a').on('click', function () {
 
            var timeoutID = window.setTimeout( function(){
                    WPViews.view_addon_maps.reload_map('map-1');
            }, 200 );
        });
    });
})( jQuery );

You may need to double-check the selector used to switch between tabs, the id of the map, and you may also have to lengthen the delay (200ms in the example) according to the speed of the animation of the tabs.