wpgmp_default_marker_icon - WP Maps Pro

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

wpgmp_default_marker_icon

The wpgmp_default_marker_icon hook in WP Maps Pro allows developers to customize the URL of the default marker icon used in maps. This hook is triggered when the default marker icon URL is being retrieved, providing an opportunity to modify it at runtime.

Usage

Developers can implement this hook in their theme’s functions.php file or through a custom plugin. It is particularly useful when you want to change the appearance of map markers globally without altering the plugin’s core files. Make sure to define a valid and accessible URL for the marker icon.

Example 1

Changing the default marker icon to a custom image hosted on your server.

add_filter('wpgmp_default_marker_icon', function($default_marker) {
    return 'http://yourwebsite.com/path-to-your-icon/custom_marker.svg';
});

Example 2

Using a marker icon from an external CDN to improve load times and reliability.

add_filter('wpgmp_default_marker_icon', function($default_marker) {
    return 'https://cdn.example.com/icons/cdn_marker.svg';
});

Example 3

Dynamically changing the marker icon based on a condition, such as the user’s role.

add_filter('wpgmp_default_marker_icon', function($default_marker) {
    if (current_user_can('administrator')) {
        return 'http://yourwebsite.com/icons/admin_marker.svg';
    }
    return $default_marker;
});

Tip: Always ensure that the URL you provide for the marker icon is accessible and properly formatted to avoid broken images on your maps. Consider using a child theme or a custom plugin for implementing this hook to prevent losing changes during updates.

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.