{"id":1951543,"date":"2022-01-10T11:03:39","date_gmt":"2022-01-10T16:03:39","guid":{"rendered":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/?post_type=tribe-knowledgebase&#038;p=1951543"},"modified":"2022-01-10T14:22:01","modified_gmt":"2022-01-10T19:22:01","slug":"change-the-google-maps-localization-option","status":"publish","type":"post","link":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/change-the-google-maps-localization-option\/","title":{"rendered":"Change the Google Maps Localization Option"},"content":{"rendered":"\n<p>By default, Google Maps sets the locale to US-based locations. This can lead to confusion if you&#8217;d like to use any other country as your default location. <\/p>\n\n\n\n<p>The good news is that you can add a filter to easily resolve this issue. In this article, we&#8217;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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-the-filter-and-snippet-example\">The filter and snippet example<\/h2>\n\n\n\n<p>The filter that you can use to modify the default location with Google Maps is <code>add_filter( 'tec_google_map_args', 'tec_customize_google_map_args', 10, 1 );<\/code><\/p>\n\n\n\n<p>To change the default location to Spain for example, you can add a snippet like the following to your functions.php file:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nadd_filter( &#039;tec_google_map_args&#039;, &#039;tec_customize_google_map_args&#039;, 10, 1 );\nfunction tec_customize_google_map_args ( $args ) {\n\t$args&#x5B;&#039;region&#039;] = &#039;es&#039;;\n\t\n\treturn $args;\n}\n<\/pre><\/div>\n\n\n<p>You can find a list of all of the available country codes <a href=\"https:\/\/www.google.com\/maps\/d\/viewer?hl=en&amp;ie=UTF8&amp;msa=0&amp;ll=-3.81666561775622e-14%2C-4.21875&amp;spn=167.755473%2C90&amp;z=1&amp;source=embed&amp;mid=1f1VuHW9fZ9alpSJkKxP3V1_UDe4\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>. <\/p>\n\n\n\n<p>You can also use the same snippet to localize the language the map is displayed in. <\/p>\n\n\n\n<p>To change the language to Spanish you need to add the following line to the above snippet, before the return:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n\t$args&#x5B;&#039;language&#039;] = &#039;es&#039;;\n<\/pre><\/div>\n\n\n<p>Important note: this will override the user&#8217;s browser settings, so use it with care! Google&#8217;s documentation on localization can be found <a href=\"https:\/\/developers.google.com\/maps\/documentation\/javascript\/localization\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By default, Google Maps sets the locale to US-based locations. This can lead to confusion if you&#8217;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&#8217;ll show you what filter to use and provide you&#8230;<\/p>\n","protected":false},"author":17,"featured_media":1955565,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_swpsp_post_exclude":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"ep_exclude_from_search":false,"footnotes":""},"categories":[59,79],"tags":[42,58],"stellar-product-taxonomy":[158,161],"class_list":["post-1951543","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-customizing-resources","category-snippets","tag-google-maps","tag-php","stellar-product-taxonomy-events-calendar-pro","stellar-product-taxonomy-the-events-calendar"],"acf":[],"taxonomy_info":{"category":[{"value":59,"label":"PHP &amp; Functions"},{"value":79,"label":"Snippets"}],"post_tag":[{"value":42,"label":"Google Maps"},{"value":58,"label":"PHP"}],"stellar-product-taxonomy":[{"value":158,"label":"Events Calendar Pro"},{"value":161,"label":"The Events Calendar"}]},"featured_image_src_large":["https:\/\/images.theeventscalendar.com\/kb\/uploads\/2023\/02\/social-share-1024x538.png",1024,538,true],"author_info":{"display_name":"Andras Guseo","author_link":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/author\/andras\/"},"comment_info":0,"category_info":[{"term_id":59,"name":"PHP &amp; Functions","slug":"customizing-resources","term_group":0,"term_taxonomy_id":59,"taxonomy":"category","description":"","parent":24,"count":101,"filter":"raw","term_order":"0","cat_ID":59,"category_count":101,"category_description":"","cat_name":"PHP &amp; Functions","category_nicename":"customizing-resources","category_parent":24},{"term_id":79,"name":"Snippets","slug":"snippets","term_group":0,"term_taxonomy_id":79,"taxonomy":"category","description":"","parent":0,"count":136,"filter":"raw","term_order":"0","cat_ID":79,"category_count":136,"category_description":"","cat_name":"Snippets","category_nicename":"snippets","category_parent":0}],"tag_info":[{"term_id":42,"name":"Google Maps","slug":"google-maps","term_group":0,"term_taxonomy_id":42,"taxonomy":"post_tag","description":"","parent":0,"count":9,"filter":"raw","term_order":"0"},{"term_id":58,"name":"PHP","slug":"php","term_group":0,"term_taxonomy_id":58,"taxonomy":"post_tag","description":"","parent":20,"count":128,"filter":"raw","term_order":"0"}],"_links":{"self":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1951543","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=1951543"}],"version-history":[{"count":1,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1951543\/revisions"}],"predecessor-version":[{"id":1955894,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1951543\/revisions\/1955894"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media\/1955565"}],"wp:attachment":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media?parent=1951543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=1951543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=1951543"},{"taxonomy":"stellar-product-taxonomy","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/stellar-product-taxonomy?post=1951543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}