Support

Account

Home Forums Front-end Issues Enqueue Google Map Reply To: Enqueue Google Map

  • Hi @rudtek

    Thanks for the reply. Can’t believe I missed the typo.

    Ok, I’ve amended the typo and tried with true (several ways) but still no joy:

    
    function prefix_enqueue_scripts() {
    
        wp_enqueue_script( 'google-maps', 'https://maps.googleapis.com/maps/api/js?key=KEY' );   
    	#wp_enqueue_script( 'google-maps', 'https://maps.googleapis.com/maps/api/js?key=KEY', true );  
    	#wp_enqueue_script( 'google-maps', 'https://maps.googleapis.com/maps/api/js?key=KEY', '', true );  
        wp_enqueue_script( 'google-map-init', get_template_directory_uri() . '/js/acf-map.js', array('jquery', 'google-maps'), '', true);
    
    }
    add_action( 'wp_enqueue_scripts', 'prefix_enqueue_scripts' );
    

    Checking the console logs, it shows:
    Google Maps JavaScript API warning: NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys

    If I check the source code, I can see the script is called but seems to get truncated:
    <script type='text/javascript' src='https://maps.googleapis.com/maps/api/js'></script>
    It’ missing the API key or is that correct?

    Thanks