Add google places api

I am trying to make sure that the google places api is in the theme,
is this the best method

    function my_acf_google_api_key( $api ){
    	
    	$api['key'] = 'zxcexample123';
    	
    	return $api;
    	
    }

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

and do I now use the $api_key = acf_get_setting(‘my_acf_google_api_key’);

in fact will this cover the google maps api error ?

Hello @wicara,

Thanks for reaching out. :slight_smile:

I inspected the website in dev tools and can see No API Keys error message showing up. Actually, until and unless you have a very specific need, you don’t need to use codes in order to add Google Maps API key. Cornerstone Maps element support the option to add API key.

Thanks.

ok but will that work on every page and allow google auto fill ?

also

Hi @wicara,

May I know what do you mean by auto-fill? It will only work to the page it’s added. May I know what kind of map you’re trying to implement or is it 3rd party related? Because it seems needed to be applied globally and stored as a custom field.

I couldn’t confirm which triggers that warning too, like if it’s the map from builder’s elements or a map added by 3rd party plugin or feature.
Thanks!

google autofill using the places api for the address fields in woocommerce need it for the billing and shipping address fields

https://developers.google.com/places/web-service/autocomplete?csw=1#location_biasing

Hi @wicara,

I see, then it’s not related to google map. It was based on the code acf/fields/google_map/api you have provided.

For that, I recommend contacting a Woocommerce developer as I myself isn’t sure how it should be implemented to those fields. It should be implemented the way it will not conflict on other Google apps/features that uses API as Google never like the redundant implementation of API libraries.

Thanks!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.