-
-
Save alaasalama/1577c8223e81785c2c887da6ad054406 to your computer and use it in GitHub Desktop.
Forked to apply this modification: https://gist.github.com/cliffordp/52d0bfb6d1537a19d158deb351dd9fa7#gistcomment-2731157 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 hidden or 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 ( 'TribeEventsPro' === $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