Support

Account

Home Forums ACF PRO Google maps API included multiple times Reply To: Google maps API included multiple times

  • Hi @mcgwd

    You should be able to do it with the load action like this:

    function autocomplete_map_init() {
        ?>
        <script type="text/javascript">
        (function($){
    
            $(document).ready(function(){
                
                // Do it after all of the assets are loaded
                acf.add_action('load', function( $el ){
                    
                    // Only execute the init function if there's a google
                    // map on the page
                    if( acf.fields.google_map.map ){
                        // execute the init function
                        initAutocomplete();
                    }
                    
                });
    
                
            });
    
        })(jQuery);
        </script>
        <?php
    }
    
    add_action('acf/input/admin_footer', 'autocomplete_map_init');

    I hope this helps 🙂