By default, Google Maps sets the locale to US-based locations. This can lead to confusion if you’d like to use any other country as your default location.

The good news is that you can add a filter to easily resolve this issue. In this article, we’ll show you what filter to use and provide you with a sample snippet that you can modify to set your default country with Google Maps.

The filter and snippet example

The filter that you can use to modify the default location with Google Maps is add_filter( 'tec_google_map_args', 'tec_customize_google_map_args', 10, 1 );

To change the default location to Spain for example, you can add a snippet like the following to your functions.php file:

add_filter( 'tec_google_map_args', 'tec_customize_google_map_args', 10, 1 );
function tec_customize_google_map_args ( $args ) {
	$args['region'] = 'es';
	
	return $args;
}

You can find a list of all of the available country codes here.

You can also use the same snippet to localize the language the map is displayed in.

To change the language to Spanish you need to add the following line to the above snippet, before the return:

	$args['language'] = 'es';

Important note: this will override the user’s browser settings, so use it with care! Google’s documentation on localization can be found here.