Home › Forums › ACF PRO › ACF_FORM Google Maps Field in Bootstrap Collapse / Accordion › Reply To: ACF_FORM Google Maps Field in Bootstrap Collapse / Accordion
Also,
I’ve read the documentation for Solving the hidden map issue.
This appears to be a solution for rendering a field where the ‘map’ variable is known. However, my issue was that with an acf_form
I did’t know what the variable for the map was. So, I went into the code a bit and found: acf.fields.google_map
(~ line 5155 in acf-input.js). From there, I worked backwards a bit and came up with:
$(document).ready(function(){
$('.panel').on('shown.bs.collapse', function () {
var this_panel = $(this);
if($(this).find('.acf-google-map').length > 0){
var acf_map = acf.fields.google_map.map;
var currCenter = acf_map.getCenter();
google.maps.event.trigger(acf_map, 'resize');
acf_map.setCenter(currCenter);
}
});
});
This seems to be working for me and hopefully it can help/work for someone else.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
ACF wouldn’t be so widely used in WordPress if it didn’t have some pretty amazing capabilities. In this article, we look at a few of the features we’ll discuss during “7 things you didn’t know you could do with ACF” at #WPEDecode later this month. https://t.co/5lnsTxp81j pic.twitter.com/Yf0ThPG1QG
— Advanced Custom Fields (@wp_acf) March 16, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.