Skip Navigation

[Résolu] Map not displaying on slidetoggle

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
A Google Map on a page is initially hidden in a closed accordion. When the accordion is expanded the map is not rendered.

Solution:
The Google Maps code that renders the map does not work if the map is hidden in a container with zero height. It is necessary to trigger a redraw of the map once the container has been expanded.

The following JS can force a re-draw of a map with id="map-1". How exactly this JS is added depends on the implementation of the accordions or tabs.

WPViews.view_addon_maps.reload_map('map-1');
This support ticket is created Il y a 6 années et 11 mois. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

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)

Ce sujet contient 5 réponses, a 2 voix.

Dernière mise à jour par marcB-6 Il y a 6 années et 11 mois.

Assisté par: Nigel.

Auteur
Publications
#597966

Link to a page where the issue can be seen : lien caché

Not able to see google map on slidetoggle.
It is working fine on page load.

#597972

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

Hi Marc

I can't see how you've built the page, but Google Maps not initially showing on a page when they are hidden in a non-active tab is a known problem (generally, not specific to Toolset Maps).

If you Google you'll find lots of suggested solutions using JavaScript, though when I handled a ticket like this before I was able to fix the issue with just the following CSS:

.tab-content > .tab-pane {
    display: block;
    height:0;
    overflow:hidden;
}

.tab-content > .tab-pane.active {
    display: block;
    height:auto;
}

That may or may not work for you depending on how you've added the tabs.

The basic problem is that if the height of the tab is zero (to hide the content) then Google will draw the map based on that height, so you need to use an alternative way of hiding the content initially using CSS (by modifying the selectors in the above if necessary), or by triggering a redraw of the map using JS once the tab is "revealed" at its full height.

#597982

As you can see in this page : lien caché
There are 3 toggles, Search, filter, on map. when you click on map it will slide toggle with map. Unfortunately we are not able to see it.

Note : Map is there but not visible due to slide toggle.

#598015

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

If a CSS-fix is not an option then you can re-render the map using JavaScript.

Where you have the code that reacts to the click on the "on map" link to reveal the map container you need to also run the following:

WPViews.view_addon_maps.reload_map('map-1');

If there is a callback to say when the animation that expands the hidden section is complete you can use that to run this snippet, but in any case it must be run after the reveal has started and the container no longer has a display: none rule.

#598076

Thanks!!

#598282

working 🙂