ACF google map field fails with sage9

I’m trying to add the Google Map field to a custom post type with advanced custom fields v4.4.11.

Unfortunately, when editing the field in the backend, the area where the map should be is blank and it prints the following error to the console

Uncaught TypeError: Cannot read property 'jquery' of null
    at Function.n.param (jquery.js?ver=1.12.4:4)
    at Object.success (input.js?ver=4.4.11:2330)
    at i (jquery.js?ver=1.12.4:2)
    at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4:2)
    at y (jquery.js?ver=1.12.4:4)
    at HTMLScriptElement.b.onload.b.onreadystatechange (jquery.js?ver=1.12.4:4)

It works, when i switch to another theme.

I’m using sage 9.0.0-beta.3 from composer.

Anybody experienced a similar issue and / or can point me to a solution?


Is jQuery in the footer while ACF is trying to use it in the page before it’s loaded? If so, you can see if moving jQuery to the header by changing true to false on this line fixes your problem:

Thanks for your answer.

No, this does not help. The loading order is the same, either way. The ACF script loads after jQuery, like it should.
Sorry, i should have made it clear, that the error is happening when trying to edit the custom field in the backend.

Aahhh, i found the error. Sorry for taking your time.
I simply forgot about namespacing, when adding the google api key and got mislead by the js error, thinking the problem lay there.

Thanks again.

1 Like

Hey shoetten, can you tell my how you fixed it? I also got to the point that it has to do with the namespacing but I am unexperienced and I don’t know how to fix it.
Thanks in advance!

Please post your code.


Hey, if it’s the same issue with the Google API key, you can add this to your setup.php

// Google maps api key for ACF
function acf_google_map_api($api) {
    $api['key'] = 'YOUR_API_KEY';
    return $api;
add_filter('acf/fields/google_map/api', __NAMESPACE__ . '\\acf_google_map_api');

or use a closure

// Google maps api key for ACF
add_filter('acf/fields/google_map/api', function ($api) {
    $api['key'] = 'YOUR_API_KEY';
    return $api;

Hope that helps…

1 Like

Thanks a lot! Works perfectly!