Hello James
Thanks for the suggestion. I’ve been looking for some code I could use to filter fields by field type across ACF Documentation with no luck. Does ACF natively support such functionality?
Hello
I’m experiencing a very similar issue to Malv – searching for any address in the Map field suddenly stopped and disabling all the plugins does not solve it.
The loading icon just keeps turning…
I worked out the code to get the Google Maps to show up on a single custom template page using ACF shown as follows:
<style type=”text/css”>
#map * {
overflow:visible;
height: 100%;
}
#map .gmnoprint .gm-style-mtc{
height: auto;
}
</style>
<div id=”map”></div>
<script>
<?php
$location = get_field(‘map’);
if( !empty($location) ):
?>
var map;
function initMap() {
map = new google.maps.Map(document.getElementById(‘map’), {
center: {lat: <?php echo $location[‘lat’]; ?>, lng: <?php echo $location[‘lng’]; ?>},
zoom: 18
});
}
<?php endif; ?>
</script>
If you want to display the map on a post listing page outside its loops, you may have to call the following upon defining $location:
global $post;
$location = get_field(‘map’, $post->ID);
For some reason, the trying the solution given at https://www.advancedcustomfields.com/resources/google-map/ only showed a gray box, which might be because of incompatibility with updated Google Maps API.
Hello loorlab
Thanks for the response.
I inserted all the code recommended above into my php files and verified that the API key entered was correct, but then again the map is a gray box.
ACF Customer Support recommened inserting the code as shown below,
but this did not resolve the problem:
global $post;
$location = get_field(‘map’, $post->ID);
One thing I noticed is that executing the code as shown below only returns ‘Array’…
Does this indicate anything?:
echo get_field(‘map’, $post->ID);
Hello
I got Google Maps showing gray (https://ibb.co/mhsPs7) after copying all the required code given at https://www.advancedcustomfields.com/resources/google-map/
into an single post template, entering an address in the map field and replacing every $location value to the one set in the ACF edit screen.
The Console tab of Chrome/Firefox returns no error. Would someone please shed some light on this? I spent two days and am not getting anywhere….
Thank you,
Ead
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.