Home Forums ACF PRO Google Maps do not display Reply To: Google Maps do not display

  • 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 * {
    height: 100%;
    #map .gmnoprint .gm-style-mtc{
    height: auto;
    <div id=”map”></div>
    $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; ?>

    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 only showed a gray box, which might be because of incompatibility with updated Google Maps API.