Support

Account

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++;