wpgmp_map_markercluster - WP Maps Pro

15000+ live websites are using this google maps wordpress plugin.

wpgmp_map_markercluster

This hook in the WP Maps Pro plugin allows developers to modify the marker cluster settings of a map. It is triggered when the map is rendering, providing an opportunity to customize how markers are clustered.

Usage

Developers can implement this hook in their theme’s functions.php file or in a custom plugin. By doing so, they can adjust the cluster settings dynamically, such as changing the grid size, max zoom level, or the icons used for clusters.

Example 1

Modify the grid size used by the marker cluster to make clusters more or less dense.

add_filter('wpgmp_map_markercluster', function($marker_cluster, $map) {
    $marker_cluster['grid'] = 20; // Change grid size to 20
    return $marker_cluster;
}, 10, 2);

Example 2

Change the cluster icons to custom images for a more personalized map appearance.

add_filter('wpgmp_map_markercluster', function($marker_cluster, $map) {
    $marker_cluster['icon'] = 'http://example.com/path/to/custom/icon.png';
    $marker_cluster['hover_icon'] = 'http://example.com/path/to/custom/hover_icon.png';
    return $marker_cluster;
}, 10, 2);

Example 3

Set a custom zoom level when clusters are clicked, providing a closer look at the clustered markers.

add_filter('wpgmp_map_markercluster', function($marker_cluster, $map) {
    $marker_cluster['marker_zoom_level'] = 15; // Set custom zoom level
    return $marker_cluster;
}, 10, 2);

Tip: Always validate and sanitize any data you modify to ensure your site remains secure and performs optimally.

Install Plugin Now!

Buy this plugin exclusively on CodeCanyon! You’ll get free updates, full support, and if you’re not satisfied, we’ve got you covered with a 30-day money-back guarantee.