Thanks for that information, I have asked our 2nd Tier supporters to take a look and passed that information along to them.
Hi Craig, here's an update for you. It appears there are two separate issues here:
1. There is a problem displaying your map View, and it is unrelated to ACF Pro. Even if I disable ACF Pro and the API Key plugin, and switch to a default theme like Twenty Seventeen, there are still problems displaying your map. For instance, often the map disappears completely when I refresh the page. I have been able to replicate this consistently on my local environment, and our developers are collaborating to resolve this issue for you.
2. There is a problem displaying your ACF maps that is unrelated to Toolset. To replicate this on my own environment, I have deactivated Toolset plugins and the API Key plugin (which should not be required) and added the following required API code to the child theme's functions.php file:
function my_acf_google_map_api( $api ){
$api['key'] = 'MY_MAP_API_KEY';
return $api;
}
add_filter('acf/fields/google_map/api', 'my_acf_google_map_api');
I replaced MY_MAP_API_KEY with my own unrestricted API key. This required code is documented here for ACF Pro:
hidden link api
Now when I go to a page like /care-housing/sheltered-housing/frank-scott-court-hawick/ the ACF Pro map is still not working correctly. I see the following errors in my JavaScript console:
• Google Maps API error: MissingKeyMapError <em><u>hidden link</u></em>
• Google Maps API warning: NoApiKeys <em><u>hidden link</u></em>
Toolset plugins are deactivated, so this second issue is something that needs to be fixed with the assistance of the ACF team. Once this issue is resolved, then we should re-evaluate the need to resolve conflicts with ACF.
Please let me know if I can help explain this further, and I will keep you up to date here as issue #1 resolution progresses.
Hi Christian,
I forwarded on the information you gave me to the devs at Advanced Custom Fields and I just received a message back from them…
------
There is a known bug in the free version of ACF which is preventing the google api key from being set.
This is not an issue in the back end.
Please note this is not an issue at all with ACF PRO which will work in the front and back as expected.
I'm assuming that you use ACF PRO, but it is possible that 'Types' have only tested with the free version
Can we confirm this before going any further?
------
So can you please let me know if you were testing with the Pro version of ACF which was installed on my dev site I sent over, or if you also tested using the free version of ACF on a different site too.
Kind regards,
Craig
Hi Craig,
I tested using the ACF plugin version you sent over in your site clone. Here's a screenshot of that. It's ACF Pro version 5.5.5. I see today that there is a new version 5.5.7 available, but I did not update.
Thanks Christian,
I have forwarded this info on to ACF support.
Kind regards,
Craig
Craig, I would like to offer a solution to issue #1 I described. Please add the following code to your theme's functions.php file:
function add_ts_map_addon_script() {
wp_enqueue_script( 'views-addon-maps-script' );
}
add_action( 'wp_enqueue_scripts', 'add_ts_map_addon_script' );
This should resolve the issue where your map disappears intermittently. I'll standby for your updates regarding ACF, and then we can determine how to proceed.
Hi Christian,
Just to let you know that I am still waiting to hear back from ACF support regarding this issue. I will chase them up and report back.
Kind regards,
Craig
After adding the code snippets above in my functions.php file in a different location it all seems to be working.
The only issue is that in the console, I am still getting an error and warning about multiple instances of the API Key and NoApiKeys (see attached screen grab). I can't see how we are supposed to get around the API key issue if ACF requires it declared in functions.php and Toolset requires it added to the Maps extension.
We can live with it for the moment since the maps all seem to be working well.
Kind regards,
Craig
OK great, it sounds like your maps are working correctly and you are able to interact with them as expected. If you experience any additional problems or loss of functionality, please feel free to reach out for further assistance.