Last active
July 8, 2020 14:42
-
-
Save cliffordp/52d0bfb6d1537a19d158deb351dd9fa7 to your computer and use it in GitHub Desktop.
Events Calendar PRO: Change default coordinates and zoom level for Map View's start location (for when there are no event results found, to avoid African coast).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Events Calendar PRO: Change default coordinates and zoom level for Map View's | |
* start location (for when there are no event results found, to avoid African coast). | |
* | |
* Change the coordinates to your liking. See the link below for a helpful tool. | |
* Updated 2018-08-06 because PRO v4.4.30 removed one of the parameters. | |
* | |
* @link https://gist.github.com/cliffordp/52d0bfb6d1537a19d158deb351dd9fa7 | |
* @link https://boundingbox.klokantech.com/ Find the coordinates of a box on a map. Selecting "DublinCore" output will be most helpful. | |
* @link https://theeventscalendar.com/support/forums/topic/africa-really/ | |
*/ | |
add_filter( 'tribe_events_pro_localize_script', 'custom_map_view_starting_geocoordinates', 10, 2 ); | |
function custom_map_view_starting_geocoordinates( $data, $object ) { | |
if ( 'tribe-events-pro' === $object ) { | |
// TODO: Tweak as needed to focus in on the desired geography (these ones are zoomed into New York City) | |
$data['geocenter'] = array( | |
'min_lat' => 40.477399, // south limit | |
'max_lat' => 40.917577, // north limit | |
'min_lng' => -73.700272, // east limit | |
'max_lng' => -74.25909, // west limit | |
); | |
if ( | |
function_exists( 'tribe_is_map' ) | |
&& tribe_is_map() | |
) { | |
// TODO: change to your preferred zoom level | |
add_filter( 'tribe_events_single_map_zoom_level', function ( $zoom_level ) { | |
return 15; | |
} ); | |
} | |
} | |
return $data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Cliff,
Might be due to some changes in EC Pro 4.4.33 the Object check in the beginning needs to be like this:
if ( 'TribeEventsPro' === $object ) {