Support

Account

Home Forums Front-end Issues Google Map – How to display? Reply To: Google Map – How to display?

  • I did try that code and its working fine on my part.

    CSS

    .acf-map {
        width: 100%;
        height: 400px;
        border: 1px solid #80d3f1;
        margin: 20px 0;
    }
    
    .acf-map .gmnoprint img {
        max-width: none; 
    }

    JS
    `jQuery(‘.acf-map’).each(function () {
    render_map($(this));
    });`

    HTML / PHP

    `function get_location_map($loc) {
    $str_ret =”;
    $str_ret .='<div class=”acf-map”>’;
    $str_ret .='<div class=”marker” data-lat=”‘.$loc[‘lat’].'” data-lng=”‘.$loc[‘lng’].'”></div>’;
    $str_ret .='</div>’;
    return $str_ret;
    }`

    $loc = will be your google map field.

    USE FUNCTION
    echo get_location_map(get_field('map'));