Support » Plugin: ACF: Google Map Extended » Oops! Something went wrong.

Viewing 9 replies - 1 through 9 (of 9 total)
  • emangham

    (@emangham)

    BUMP. I have the same issue, any resolution?

    Hi guys,

    1.- Create a new api key of google maps (https://developers.google.com/maps/documentation/javascript/get-api-key)
    2.- Search this files (acf-google-map-extended-v4.php & acf-google-map-extended-v5.php) on plugins\advanced-custom-fields-google-map-extended\ and edit the lines 28 and 27 respectively
    3.- Add “key=YOUR_API_KEY” followed by “//maps.googleapis.com/maps/api/js?”

    Vibes.
    PD: Sorry for my english.

    The plugin author should’ve added a filter call where you can insert you API key, as supported by the regular ACF Google Maps field.

    This is what I was able to do to get it working again.

    https://www.advancedcustomfields.com/blog/google-maps-api-settings/

    The code below is for ACF Standard. You can find the code for ACF Pro by going to the link above. Just insert it into your theme’s functions.php file and it should work.

    function my_acf_google_map_api( $api ){
    	
    	$api['key'] = 'YOUR_API_KEY';
    	
    	return $api;
    	
    }
    
    add_filter('acf/fields/google_map/api', 'my_acf_google_map_api');

    Is this really working when using this Extended plugin?

    It does not for me – isn’t the filter shown above using the standard ACF field: google_map?

    As far as I can tell, this plugin does not (yet) have a way to provide a user key.
    Hopefully it will be updated soon in the same way ACF Google Map fixed it months ago.
    The code in plugins/advanced-custom-fields-google-map-extended/*php only creates this code:

    <script type='text/javascript' src='//maps.googleapis.com/maps/api/js?v=3&sensor=false&libraries=places&ver=3'></script>

    As long as this plugin is installed, even ACF standard Google Map field will fail.

    Only thing that worked for: Deactivate (or delete) this plugin, then the stanard ACF Google Map field starts working again with the filter mentioned in the previous comment.

    Hope this gets fixed soon!

    @bwooster47,

    I just assumed the filter would work as a tie-in for the ACF plugin. As far as I know, as long as an API key is provided, it should work. Maybe the Extended plugin gives it’s own filter and cancels out that of the ACF plugin itself? If so, maybe having your filter called with a higher priority might work. Possibly something like changing…

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

    to…

    add_filter('acf/fields/google_map/api', 'my_acf_google_map_api', 999);

    No luck – changing filter priority does nothing because ACF uses a different mechanism to pass the key to Google.
    Here are my tests and results:

    Editing a page that has only a standard ACF Google Map Field. Using a filter as shown in my_acf_google_map_api above.

    1: Deactivate Google Map Extended. The map displays fine when Editing the page in wordpress.
    Looking at the source, I only see one line with the key:
    acf.fields.google_map.api = {“libraries”:”places”,”key”:”MY-KEY-HERE”};
    There is no script line to maps.googleapis.com in the HTML source.

    2: Activate Google Map Extended, but do not add any fields.
    Go back to Edit Page, and now the map errors out – no map.
    Look at the page source, and I do see the ACF line shown above, but now before that, I also see this line in the HTML source:
    <script type='text/javascript' src='//maps.googleapis.com/maps/api/js?v=3&sensor=false&libraries=places&ver=3'></script>
    This is always unconditionally added by input_admin_enqueue_scripts functions in plugins/advanced-custom-fields-google-map-extended PHP files.

    I suspect the problem is in those files. The script for maps.googleapis.com should not be loaded in that manner any more.

    3: Deactivate Google Map Extended, and all is fine, map is displayed.

    well shoot. thought i might’ve had the solution, but i can’t get it to work either. even with deregistering the Maps Extended Google script and replacing it with my own link to the API, it still doesn’t work. i’m stumped on this one. 🙁

    Based on the testing I reported, the plugin author needs to make some updates.

    Possible fix:

    1: Remove the first line, and remove googlemaps-api from second line:

        wp_register_script("googlemaps-api", "//maps.googleapis.com/maps/api/js?v=3&sensor=false&libraries=places",array(),'3',false);
        wp_register_script($this->settings['script-handle'], $this->settings['url'] . '/js/input.js', array($this->settings['acf-script-handle'],'jquery','googlemaps-api'), $this->settings['version'],fals
    

    2: Use the key – find out how the parent plugin is using the key – it sets this variable:
    acf.fields.google_map.api = {“libraries”:”places”,”key”:”MY-KEY-HERE”};

    Unfortunately, this pluing inherits from acf_field and not acf.fields.google_map:
    class acf_field_google_map_extended extends acf_field
    If that can be changed to inherit from acg.field.google_map, then the extended class has access to the key too, setup using the same filter that ACF uses.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Oops! Something went wrong.’ is closed to new replies.