Home › Forums › General Issues › Multiple Google Map Marker Icons › Reply To: Multiple Google Map Marker Icons
Hi @atmacmillan
Since you’re using PHP in the script I’ll assume you’re running this not in a js file but directly in the template.
You could setup a repeater-field with an image field inside.
Then do something like:
//This goes outside the marker loop
<?php $images_repeater = get_field('repeater_field'); ?>
var i = 0; //This is a JS variable we use as a counter
//This I assume is inside the marker loop
// var
var latlng = new google.maps.LatLng( $marker.attr(‘data-lat’), $marker.attr(‘data-lng’) );
var image = '<?php echo $images_repeater[ ?>i<?php]['image_field']['url']; ?>'; //Im not sure wether this even works.. never tried it ;)
// create marker
var marker = new google.maps.Marker({
position : latlng,
map: map,
icon: image
});
//end of marker loop
i++;
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.