Ashish Patel
Ashish Patel

Reputation: 1031

Getting Google Maps API warning: in ACF Google Map Wordpress

I am Getting Google Maps API warning: in ACF googlemap type field Wordpress BACKEND when i am going to enter address in page, I know this i have to add google map api key but where do i have to? enter image description here

Map doesn't load when i enter address... enter image description here

Upvotes: 1

Views: 824

Answers (2)

atazmin
atazmin

Reputation: 5687

From https://www.advancedcustomfields.com/resources/google-map/ if there still error, the error on developers console should have an explanation and a link how to fix it

// Method 1: Filter.
function my_acf_google_map_api( $api ){
    $api['key'] = 'xxx';
    return $api;
}
add_filter('acf/fields/google_map/api', 'my_acf_google_map_api');

// Method 2: Setting.
function my_acf_init() {
    acf_update_setting('google_api_key', 'xxx');
}
add_action('acf/init', 'my_acf_init');

Upvotes: 0

Ayline
Ayline

Reputation: 31

You have to add this code to functions.php:
Change xxx with you api-key.

function my_acf_google_map_api( $api ){

    $api['key'] = 'xxx';

    return $api;

}

add_filter('acf/fields/google_map/api', 'my_acf_google_map_api');

Hope it helps! :)

Upvotes: 1

Related Questions