Skip Navigation

[Resolved] Show Google Map in Bootstrap Collapse element

This thread is resolved. Here is a description of the problem and solution.

Problem: I am including a Map View inside a collapsed element (using Bootstrap Collapse). When the collapsed element is shown, the Map does not appear.

Solution: Add a JavaScript event handler that reloads the Map when the collapsed element is shown. Wrap your code in a jQuery document ready handler:

jQuery(document).ready(function(){
  jQuery('#collapseExample').on('shown.bs.collapse', function(){
    WPViews.view_addon_maps.reload_map('map-2');
  });
});

Relevant Documentation:
https://getbootstrap.com/docs/4.0/components/collapse/

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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 20 replies, has 2 voices.

Last updated by Christian Cox 6 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#613864

The code isn't wrapped in a document ready handler, so there could be a race condition (sometimes it works, other times it does not). Add the event handler wrapper around this code and see if that helps:

jQuery(document).ready(function(){
  jQuery('#collapseExample').on('shown.bs.collapse', function(){
    WPViews.view_addon_maps.reload_map('map-2');
  });
});
#613875

Hi Christian,

It doesn't help. It shows a blank map and when I swipe it will show me the world overview map. What did I do to get this? So strange! What can we do?

#613877

Maybe this is a new topic but the reset button works but the results are a list without images per item. WhenI refresh it will show the images. Is this something that is bothering the map too?

#613891

It appears that the map with ID "map-2" no longer exists. Did you remove the map shortcode, or modify the map ID in that shortcode?

#613899

I took a look and indeed it was gone and switched to 1 again. This is very stupid. I probably saved an open window on different computer. I am really learning a lot. Thanks so much for this marvelous support.

Any ideas o the reset button?

#613910

Not entirely sure about that...It will require some additional investigation. I have split that topic into a new ticket where we can follow up.