Home Forums Backend Issues (wp-admin) Google Maps field needs setting to add API key Reply To: Google Maps field needs setting to add API key

  • I’m sure if it wasn’t for this the Beta version wouldn’t be available to be honest. There are several other new features in it that are still a bit buggy.

    Once you update to the Beta you need to set up a Google Map api Key

    I have not used this yet, so I’ve been looking at the code. It appears that Elliot has set this up to work on a filter, at least for now. I don’t see a place in ACF where you can enter the values and maybe he plans to add this later. At any rate, here is the relevant code from ACF

       	*  input_admin_footer
       	*  description
       	*  @type	function
       	*  @date	6/03/2014
       	*  @since	5.0.0
       	*  @param	$post_id (int)
       	*  @return	$post_id (int)
       	function input_admin_footer() {
    	   	// vars
    	   	$api = array(
    			'libraries'		=> 'places',
    			'key'			=> acf_get_setting('google_api_key'),
    			'client'		=> acf_get_setting('google_api_client')
    	   	// filter
    	   	$settings = apply_filters('acf/fields/google_map/api', $api);
    	   	// remove empty
    	   	if( empty($api['key']) ) unset($api['key']);
    	   	if( empty($api['client']) ) unset($api['client']);
    <script type="text/javascript">
    acf.fields.google_map.api = <?php echo json_encode($api); ?>;

    It appears that you’ll need to create a filter in functions.php to set up the api key.