Skip to content

Instantly share code, notes, and snippets.

@cliffordp
Forked from jesseeproductions/tribe-google-map-region
Last active August 29, 2018 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cliffordp/c7c2713e9f61166e9aef746823be6bfa to your computer and use it in GitHub Desktop.
Save cliffordp/c7c2713e9f61166e9aef746823be6bfa to your computer and use it in GitHub Desktop.
The Events Calendar and/or PRO: Set Region and Language biasing for Google Maps (Australia in this example)
<?php
/**
* The Events Calendar and/or PRO: Set Region and Language biasing for Google Maps.
*
* @link https://gist.github.com/cliffordp/c7c2713e9f61166e9aef746823be6bfa This snippet.
* @link https://developers.google.com/maps/faq#languagesupport Language Codes.
* @link https://developers.google.com/maps/documentation/javascript/geocoding#GeocodingRegionCodes Region codes.
*
* @param string $api_url The Google Maps API URL.
*
* @return string
*/
function tribe_add_google_map_region( $api_url ) {
if ( ! empty( $api_url ) ) {
// !!! TODO: change these as required for your language and location. This is set to Australia!!!
$api_url = add_query_arg( [
'language' => 'en-Au', // English (Australian)
'region' => 'AU', // Australia
], $api_url );
}
return $api_url;
}
// Google Maps for The Events Calendar (such as Single Event page's venue location map)
add_filter( 'tribe_events_google_maps_api', 'tribe_add_google_map_region' );
// Google Maps for Events Calendar PRO's (such as geolocation and Map View)
add_filter( 'tribe_events_pro_google_maps_api', 'tribe_add_google_map_region' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment