wpgmp_map_options - WP Maps Pro

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

wpgmp_map_options

This hook allows developers to customize map settings at runtime in the WP Maps Pro plugin. It is triggered before displaying the map, providing an opportunity to modify the map’s configuration.

Usage

Developers can implement this hook within their theme’s functions.php file or a custom plugin. It provides a way to adjust map settings dynamically, such as changing the map’s center, zoom level, or appearance, based on specific conditions or requirements.

Example 1

Change the map’s zoom level to 5 before rendering the map.

add_filter('wpgmp_map_options', 'custom_map_zoom_level');
function custom_map_zoom_level($map_options) {
    $map_options['zoom'] = 5;
    return $map_options;
}

Example 2

Set the map type to SATELLITE for a different viewing experience.

add_filter('wpgmp_map_options', 'custom_map_type');
function custom_map_type($map_options) {
    $map_options['map_type_id'] = 'SATELLITE';
    return $map_options;
}

Example 3

Modify the center marker icon to a custom SVG image.

add_filter('wpgmp_map_options', 'custom_center_marker_icon');
function custom_center_marker_icon($map_options) {
    $map_options['center_marker_icon'] = 'data:image/svg+xml;charset=UTF-8,...'; // Custom SVG data
    return $map_options;
}

Tip: Always validate and sanitize any external data before using it to modify map options to ensure security and prevent potential vulnerabilities.

Install Plugin Now!

WP MAPS PRO helps you create dynamic, customizable maps using Google Maps or Leaflet — no coding required. Includes free updates, premium support, and a 30-day money-back guarantee.