Gists

4 years ago
<?php

// Add to your (child) theme's functions.php
// Prevent marker clustering from a specific zoom level and up
// https://facetwp.com/help-center/facets/facet-types/map/#set-the-maximum-zoom-level-for-a-cluster-to-appear

add_filter( 'facetwp_map_init_args', function( $settings ) {
    if ( isset( $settings['config']['cluster'] ) ) {
        $settings['config']['cluster']['maxZoom'] = 10; // default: 15. Level must be between 1 and 20.
    }
    return $settings;
});
5 years ago
<?php

add_filter( 'facetwp_map_init_args', function( $settings ) {
    if ( isset( $settings['config']['cluster'] ) ) {
        $settings['config']['cluster']['zoomOnClick'] = true;
    }
    return $settings;
});
4 years ago
<?php

// Add to your (child) theme's functions.php
// For more examples and explanation, see: 
// https://facetwp.com/help-center/facets/facet-types/map/#set-custom-marker-cluster-images

add_filter( 'facetwp_map_init_args', function( $settings ) {

  $clustericonsizes = array( 53, 56, 66, 78, 90 );  // specify icon image sizes. These are the default values.
  for ( $i = 1; $i <= 5; $i ++ ) {
    $settings['config']['cluster']['styles'][] = [
      'url'       => FACETWP_MAP_URL . '/assets/img/m' . $i . '.png', // directory, required. This is the default directory.
      'width'     => $clustericonsizes[ $i - 1 ], // required
      'height'    => $clustericonsizes[ $i - 1 ], // required
      'textColor' => '#ffffff', // white, optional
      'textSize'  => 16 // 16px, optional
    ];
  }

  return $settings;
} );
4 years ago
<?php
/** be sure your link has a data-id attribute with the postid and a data-lat attribute with the latitude
 **/

add_action( 'wp_head', function() { ?>
    <script>
        (function($) {
            $( 'body' ).on( 'click', '.post-item', function(e) {
            e.preventDefault(); // Necessary if '.post-item' is an <a> tag and you don't want it to open the post page itself.
            var postid = $(this).attr('data-id');
            var postlat = $(this).attr('data-lat');  // add a data-lat to the <a> tag with the location's latitude value
            var marker = FWP_MAP.get_post_markers(postid);
            $.each( marker, function( key, value ) {	    
                if ( value.position.lat() == postlat ) {
                FWP_MAP.map.setCenter({
                lat: value.position.lat(),
                lng: value.position.lng()
                });
                FWP_MAP.is_zooming = true; // Needed if you are using the "Enable map filtering" button
                FWP_MAP.map.setZoom(17); // Set a zoom level between 1 and 20. Make sure it is higher than the marker clusterer's bottom limit.		
                // google.maps.event.trigger(value, 'click'); // If you don't have spiderfied markers
                google.maps.event.trigger(value, 'spider_click'); // If you have spiderfied markers. Will also work if you don't have spiderfied markers.	    
                }
            });
	    });
	})(jQuery);
    </script>
<?php } );
6 years ago
<?php

/**
 * This assumes a "gmaps" folder within your theme
 * Within that folder, add m1.png, m2.png, m3.png, m4.png, m5.png
 */
add_filter( 'facetwp_map_init_args', function( $settings ) {
    $settings['imagePath'] = get_bloginfo( 'stylesheet_directory' ) . '/gmaps/m';
    return $settings;
});
7 years ago
<?php

add_filter( 'facetwp_map_init_args', function( $settings ) {
    $settings['imagePath'] = 'URL/TO/YOUR/IMG/FOLDER/m'; // e.g. https://yoursite.com/images/m';
    return $settings;
});