<?php
/** basic check to keep only one map marker per location
** assumes lat is unique without having to check lng also
**/
Class FWPMapDulicateChecker
{
public $locations = [];
function __construct() {
add_filter( 'facetwp_map_marker_args', function( $args, $post_id ) {
$lat = $args['position']['lat'];
if ( false === array_search( $lat, $this->locations ) ) {
$this->locations[] = $lat;
} else {
return false;
}
return $args;
}, 10, 2 );
}
}
new FWPMapDulicateChecker();