Support » Plugin: Advanced Custom Fields » Google Maps api key

Viewing 6 replies - 1 through 6 (of 6 total)
  • I am also facing the issue, whats worse is my page is not even loading properly due to errors generated by map.

    This is the only solution I have found at the moment until the plugin author comes up with a better solution. You have to create your key with Google APIs. You will then need to add the key to:

    advanced-custom-fields/js/input.js
    advanced-custom-fields/js/input.min.js

    input.js is a bit easier to find. On line 2282 you will see:

    if( typeof google === 'undefined' )
    {
    	$.getScript('https://www.google.com/jsapi', function(){
    
                    google.load('maps', '3', { other_params: 'sensor=false&libraries=places', callback: function(){
    
    			        $fields.each(function(){
    
    						acf.fields.google_map.set({ $el : $(this) }).init();
    
    					});
    
    			    }});
    			});
    
    		}
    		else
    		{
    			google.load('maps', '3', { other_params: 'sensor=false&libraries=places', callback: function(){
    
    				$fields.each(function(){
    
    					acf.fields.google_map.set({ $el : $(this) }).init();
    
    				});
    
    		    }});
    
    		}

    At the end of places (inside the ‘), you need to add:

    &key=*YOUR_API_KEY*

    So it will look like:

    google.load('maps', '3', { other_params: 'sensor=false&libraries=places&key=*YOUR_API_KEY*', callback: function(){

    It is harder to find in the min file for obvious reasons, so well tailored Find/Replace will work here.

    I will say that the min file is what is read from the back end, so it is the file you have to make this edit to.

    Hope that helps.

    Thanks bobbydank,

    This can fix the problem for now. I am only worried if someone updated the plugin, this has to be done again. But we have no other option until ACF releases an update and fix this issue.

    Hi Bobbydank,

    Thank you for your suggestion, but it does not work for me.
    I have placed the right API-key in the right 4 places (with and without *) and still I get in front the warning: “Google Maps API warning: NoApiKeys”
    In back-end the error: “invalid Api-key”
    I get the same warning in front without adding Api-keys. In back-end the map is showing up without adding API-key. No caching at all. Newest WP and ACF.
    I renewed the correct API-key (and waited an hour), without result.
    Would be nice to get some suggestions.

    To be complete: I have a JS browser key en added my domain correctly.

    If you are using free ACF plugin add following code in your function.php file. Replace your google maps API key with “xxx”.

    if(is_admin()):
    function my_acf_google_map_api($api){
    $api[‘key’] = ‘xxx’;
    return $api;
    }
    add_filter(‘acf/fields/google_map/api’, ‘my_acf_google_map_api’);
    endif;

    If you are using ACF pro plugin, then add following code in your function.php file

    if(is_admin()):
    function my_acf_init() {
    acf_update_setting(‘google_api_key’, ‘xxx’);
    }
    add_action(‘acf/init’, ‘my_acf_init’);
    endif;

    > Note: Most important things that you have to keep in mind for the best
    > solution of above issue. If you are using ACF pro plugin then you must
    > enter ACF pro plugin activation key. After inserting the key in plugin
    > check your backend your issue is solved.

    For more information you can visit here : http://www.krazzycodes.com/google-map-not-showing-in-wordpress-backend-acf-plugin/

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Google Maps api key’ is closed to new replies.