<?php
/**
* Set marker content specific to the ACF repeater locaton.
* Change 'locations_multi' to the name of the ACF repeater field.
* Change 'store' to the name of the Google Map field within the repeater field.
* Add other or different code as needed to $args['content']. This overwrites anything in the 'Marker content' setting.
* For more info and an example on how to use other custom fields within the repeater field, see:
* https://facetwp.com/help-center/facets/facet-types/map/#add-marker-content-from-acf-repeater-fields
**/
add_filter( 'facetwp_map_marker_args', function( $args, $post_id ){
$latitude = $args['position']['lat'];
$locations = get_field( 'locations_multi', $post_id );
foreach ( $locations AS $location ) {
if ( (string)$location['store']['lat'] == (string)$latitude ) {
$args['content'] = $location['store']['address']; // Retrieves Google address from the Google Map field.
// Or:
// $args['content'] = $location['other_field']; // Retrieves value from another custom field in the repeater
break;
}
}
return $args;
}, 10, 2 );