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'));
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.