Home › Forums › Front-end Issues › ACF front-end form Google Maps + Regular Maps
Hi There,
I’m running into a little issue. I’ve followed this FAQ-article:
https://www.advancedcustomfields.com/resources/google-map/
To try and make a Google Map displaying my posts as markers. This works if it’s stand alone, but on the same page you have a front-end submission form wich also contains a Google Maps fields.
Because of that front-end form the maps api is loaded twice, and doesn’t work.
And if i remove the script it says ‘google’ is not defined and only the little map in the frond-end field works.
Any ideas how I can make it work with both maps on the same page?
Thanks in advance
Hi @len
For the page with a front end form, could you please remove the Google Maps script inclusion? Then, instead of this code:
$(document).ready(function(){
$('.acf-map').each(function(){
// create map
map = new_map( $(this) );
});
});
Could you please use the following code instead?
acf.add_action('load', function( $el ){
$('.acf-map').each(function(){
// create map
map = new_map( $(this) );
});
});
This code will make sure that ACF’s assets are loaded first, including the Google Maps script inclusion by ACF. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/.
I hope this helps 🙂
Hi James,
I have a similar issue, but I’m a bit unsure how to implement the fix.
The first map works fine and shows locations.
The google map in the form to submit new locations, however, does not work –
I have tried removing the script – that removes the top google map but the map in the submission form still doesnot show.
Any ideas?
Thanks for your help
Patrick
The topic ‘ACF front-end form Google Maps + Regular Maps’ is closed to new replies.
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.