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!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.