Support

Account

Home Forums ACF PRO Map Field /API Key

Helping

Map Field /API Key

  • I am trying to understand how this API Key piece works. I have add this to my functions.php.

    // SET Google Map Key for ACF
    function my_acf_init() {
    	
    	acf_update_setting('google_api_key', 'mykeygoeshere'); 
    }
    
    add_action('acf/init', 'my_acf_init');

    and the enables the backend/admin map field, but not the frontend. It seems like I have to append the key to script like so:
    wp_enqueue_script( 'cs-google-map', 'http://maps.googleapis.com/maps/api/js?sensor=false&key=mykeygoeshere', array(), '20130115', false );

    Is this best practice? I guess I would need to protect my key as it’s public visible.

  • It appears that this is the way to do it, yes. It is explained under template usage here https://www.advancedcustomfields.com/resources/google-map/. I don’t know anything about protecting the key. I actually use a different plugin for google maps gut the key is easily available in the source of the page. When I set up the key I set it up so that it can only be used by specific domain names.

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

The topic ‘Map Field /API Key’ is closed to new replies.