Skip Navigation

[Resuelto] Map not displaying on slidetoggle

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

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 hace 6 años, 11 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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)

Este tema contiene 5 respuestas, tiene 2 mensajes.

Última actualización por marcB-6 hace 6 años, 11 meses.

Asistido por: Nigel.

Autor
Mensajes
#597966

Link to a page where the issue can be seen : enlace oculto

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

#597972

Nigel
Supporter

Idiomas: Inglés (English ) Español (Español )

Zona horaria: 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 : enlace oculto
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

Idiomas: Inglés (English ) Español (Español )

Zona horaria: 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 🙂