I have a google map that is looping through and custom post type to place location markers based on the Advanced Custom Fields map input.
This is working perfectly. I have then managed to create a custom marker image for all the map points, again working perfectly.
I want to be able to have different map markers depending on if an ACF is ticked or not. For example -
if( get_field('coming_soon') )
{
iconBase + 'purple-flag.png'
}
else
{
iconBase + 'green-flag.png'
}
Here is my existing code, what do I need to do to get this working?
// var
var latlng = new google.maps.LatLng( $marker.attr('data-lat'), $marker.attr('data-lng') );
var iconBase = '<?php echo get_template_directory_uri(); ?>/images/';
var marker_image = new google.maps.MarkerImage(
iconBase + 'green-flag.png',
null,
// The origin for my image is 0,0.
new google.maps.Point(0, 0),
// The center of the image is 50,50 (my image is a circle with 100,100)
new google.maps.Point(0, 40)
);
// create marker
var marker = new google.maps.Marker({
position : latlng,
map : map,
icon: marker_image
});
Aucun commentaire:
Enregistrer un commentaire