How to filter the FacetWP Google Maps options

Learn how to filter the arguments passed to FacetWP Google Maps and in this case disable scrollwheel zoom.

This morning I was helping to work out some issues with a site using FacetWP and came across a useful filter contained within the Facet WP Google Maps addon.

Documentation for the Google Maps addon is a little sparse at the moment, so I thought it would be helpful to highlight the facetwp_map_init_args filter, which allows you to update the default Google Map options.

In this case we wanted to disable the scrollwheel zoom, so added the following code to functions.php.

add_filter( 'facetwp_map_init_args', 'prefix_prevent_scroll_zoom_on_facet_map' );
* Filter the Google Map options to prevent scrollwheel zoom.
* @link
* @param array $args Array of init settings for Google map.
* @return array $args Modified array.
function prefix_prevent_scroll_zoom_on_facet_map( $args ) {
$args['init']['scrollwheel'] = false;
return $args;
view raw functions.php hosted with ❤ by GitHub

Other Google Maps options can be set using the filter, such as preventing the map being draggable or removing the default map controls.

Leave a Reply