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 https://developers.google.com/maps/documentation/javascript/get-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); ?>;
</script>
<?php
}
}
It appears that you’ll need to create a filter in functions.php to set up the api key.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.