Home › Forums › Front-end Issues › ACF Google Maps Rendering › Reply To: ACF Google Maps Rendering
Hey @bigdropgr what I used was an onclick function on one of my tab buttons. Specifically this part of my code is what renders the map and resizes it to 100% width and height:
$(document).ready(function(){
$( ".mapclick" ).one( "click", function() {
//$('.mapclick').click(function(event) {
$('.acf-map').each(function(){
render_map( $(this) );
});
$(window).resize(function() {
$('.acf-map').height($(window).height() - 170);
});
$(window).trigger('resize');
});
//$height = $('#wrapper').height();
//$('.acf-map').height($height);
});
So on one of my tab buttons, I have the class name “mapclick”. Then in my code, I have when the button “mapclick” is clicked, render the map and resize.
Here is my tabs code:
<ul class="products-list">
<li class="active info countbutton"><a href="#info"><span class="text">Info</span></a></li>
<li class="photo countbutton"><a href="#photo" class="photoclick"><span class="text">Photos</span></a></li>
<li class="video countbutton"><a href="#video"><span class="text">Videos</span></a></li>
<li class="map countbutton"><a href="#map" class="mapclick"><span class="text">Maps</span></a></li>
<li class="hour countbutton"><a href="#hour"><span class="text">Hours</span></a></li>
</ul>
Let me know if this makes sense.
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!
❓Ever wondered when and why ACF uses JSON instead of the database? Check out our summary of the most recent session of ACF Chat Friday for the answer, and make sure to register for the next session.
— Advanced Custom Fields (@wp_acf) February 23, 2023
👉 https://t.co/3UtvQbDwNmhttps://t.co/wfFEVcXVKc
© 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.