This hook in the WP Maps Pro plugin allows developers to customize the street view settings of a map at runtime. It is particularly useful for modifying parameters like street control visibility, view orientation, and other street view options.
Usage
Developers can implement this hook in their theme’s functions.php file or within a custom plugin. It provides flexibility to adjust street view settings dynamically based on specific conditions or preferences. Practical tips include ensuring the map data object is correctly passed and verified for null or unexpected values.
Example 1
In this example, we customize the street view settings to disable the street view close button.
add_filter('wpgmp_map_streetview', 'custom_street_view_settings', 10, 2); function custom_street_view_settings($map_data, $map) { $map_data['street_view']['street_view_close_button'] = false; return $map_data; }
Example 2
This example demonstrates how to enable the links control in the street view settings.
add_filter('wpgmp_map_streetview', 'enable_links_control', 10, 2); function enable_links_control($map_data, $map) { $map_data['street_view']['links_control'] = true; return $map_data; }
Example 3
Here, the POV heading and pitch are adjusted to provide a specific view angle.
add_filter('wpgmp_map_streetview', 'adjust_pov_view', 10, 2); function adjust_pov_view($map_data, $map) { $map_data['street_view']['pov_heading'] = '90'; $map_data['street_view']['pov_pitch'] = '30'; return $map_data; }
Tip: Always validate and sanitize any data being modified to prevent potential security vulnerabilities or map display issues.