Support

Account

Home Forums Backend Issues (wp-admin) TypeError: google.load is not a function

Solving

TypeError: google.load is not a function

  • Hi,

    I just installed version 4.3.8 of Advanced Custom Fields on a WordPress 3.9 site using a Boostrap2 theme. I am trying to get the WYSIWIG editor and Google Map fields to work.

    I saw the FAQ about the editor not working due to JS errors. The JS error I am getting is: TypeError: google.load is not a function
    from this file:
    /wp-content/plugins/advanced-custom-fields/js/input.min.js?ver=4.3.8.
    It looks like your JS file has an error.

    I gather this is stopping both the editor field and Google Map field from working.

    What do I need to do to fix the JS error?

    Thank you.

  • Hi there,

    I am also having this trouble. It seems there is a conflict with another plugin I need to use called wp store locator http://wordpress.org/plugins/wp-store-locator/ as it will work when this plugin is deactivated. Is there a way around this, as unfortunately I need both plugins to work?

    Thanks in advance

  • Hi, I’m having the same problem. It seems a conflict with the maps loaded by my Divi theme for integrated page builder.

    TypeError: google.load is not a function
    /wp-content/plugins/advanced-custom-fields/js/input.js?ver=4.4.1
    Line 2300

    Without the page builder (who uses maps too) there are no errors.

  • My work-around is a double check as the following code to substitute the function on line 2268:

    	$(document).on('acf/setup_fields', function(e, el) {
    
    		// vars
    		$fields = $(el).find('.acf-google-map');
    
    		// validate
    		if (!$fields.exists()) {
    			return;
    		}
    
    		// validate google
    		if (typeof google === 'undefined') {
    			$.getScript('https://www.google.com/jsapi', function() {
    
    				google.load('maps', '3', {
    					other_params: 'sensor=false&libraries=places',
    					callback: function() {
    
    						$fields.each(function() {
    
    							acf.fields.google_map.set({
    								$el: $(this)
    							}).init();
    
    						});
    
    					}
    				});
    			});
    
    		} else {
    
    			if (typeof google.load != 'function') {
    				$.getScript('https://www.google.com/jsapi', function() {
    
    					google.load('maps', '3', {
    						other_params: 'sensor=false&libraries=places',
    						callback: function() {
    
    							$fields.each(function() {
    
    								acf.fields.google_map.set({
    									$el: $(this)
    								}).init();
    
    							});
    
    						}
    					});
    				});
    
    			} else {
    
    				google.load('maps', '3', {
    					other_params: 'sensor=false&libraries=places',
    					callback: function() {
    
    						$fields.each(function() {
    
    							acf.fields.google_map.set({
    								$el: $(this)
    							}).init();
    
    						});
    
    					}
    				});
    
    			}
    
    		}
    
    	});
    
  • Had this same issue and Diac’s solution worked, though it’ll overwritten with any updates.

  • Diac’s solution worked for me as well. Don’t forget to replace the minified file. I tried including it in the footer with a hook, but it does actually need to replace the original lazy loader. This looks to be a robust enough solution to include in master.

    Other threads have been saying “find the other plugin that loads the google maps api and disable it”. I’m sick to death of plugin developers saying things like that. I know a lot of people have unnecessary plugins, but I don’t. Until WordPress has front-end dependency management (seems to be at least a 3 years late to that party), plugin developers have to be extra cautious with dependencies (and class namespaces, etc). Don’t just dismiss any plugin that isn’t yours.

  • Hi, can someone share their minified js file? I tried to use Diac’s solution without any luck. Thank you.

  • I believe I just used an online uglifier. Here ya go:

    https://gist.github.com/archonic/b152ef9d35e67cdb09d1

Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘TypeError: google.load is not a function’ is closed to new replies.