{"id":1959290,"date":"2024-01-30T07:51:50","date_gmt":"2024-01-30T12:51:50","guid":{"rendered":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/?p=1959290"},"modified":"2025-03-17T14:11:20","modified_gmt":"2025-03-17T18:11:20","slug":"how-location-search-works-in-events-calendar-pro","status":"publish","type":"post","link":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/how-location-search-works-in-events-calendar-pro\/","title":{"rendered":"How Location Search Works in Events Calendar Pro"},"content":{"rendered":"\n<iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/7Oj5hDMu_Xk?si=Pe3pkRtLpPxnB26N\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n\n\n\n<p><a href=\"https:\/\/theeventscalendar.com\/product\/wordpress-events-calendar-pro\/\" target=\"_blank\" rel=\"noreferrer noopener\">Events Calendar Pro<\/a> offers the ability to perform smart location-based searches when filtering calendar events. This article aims to provide insight into how location search works in the background through the Google Maps API. If you&#8217;re interested in how to use location search, then head over to <a href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/events-calendar-pro-location-search\/\" target=\"_blank\" rel=\"noreferrer noopener\">this article<\/a>.<\/p>\n\n\n\n<p>This requires Events Calendar Pro to be installed with a custom, unrestricted Google Maps API key, or <strong>better, a set of restricted API keys<\/strong>, which were set up based on our <a href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/using-google-maps-api-key-restrictions\/\" target=\"_blank\" rel=\"noreferrer noopener\">Creating Google Maps API Key Restrictions article<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-does-the-search-happen\">How does the search happen?<\/h2>\n\n\n\n<p>When you are on a calendar page, you have a dedicated field for location search, as seen in this screenshot.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"2362\" height=\"150\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-1.41.55-PM-1.png\" alt=\"\" class=\"wp-image-1949940\" srcset=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-1.41.55-PM-1.png 2362w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-1.41.55-PM-1-300x19.png 300w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-1.41.55-PM-1-1024x65.png 1024w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-1.41.55-PM-1-768x49.png 768w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-1.41.55-PM-1-1536x98.png 1536w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-1.41.55-PM-1-2048x130.png 2048w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-1.41.55-PM-1-1568x100.png 1568w\" sizes=\"auto, (max-width: 2362px) 100vw, 2362px\" \/><\/figure>\n\n\n\n<p>When you enter a phrase and click on <em>Find Events<\/em>, a request is sent to the Google Maps API in the background, which looks like this:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; auto-links: false; gutter: false; title: ; quick-code: false; notranslate\" title=\"\">\nhttps:\/\/maps.googleapis.com\/maps\/api\/geocode\/json?address=search-term&amp;amp;key=AIza-enter-your-API-key-here\n<\/pre><\/div>\n\n\n<p>The <code>search-term<\/code> will be the phrase you typed in the &#8220;In a location&#8221; field, and the <code>key<\/code> will be your custom Google Maps API key.<\/p>\n\n\n\n<p>The API will try to find a result and return that to the site.<\/p>\n\n\n\n<p><em>You can run a request URL like the above in your browser &#8211; substituting the search term and the key with yours &#8211; and see the results the API sends back.<\/em><\/p>\n\n\n\n<p>The site will then take the latitude and longitude coordinates that come with the result and will run a search within the existing venues (with saved latitude and longitude coordinates) using the search radius you set up under <em>Events \u2192 Settings \u2192 Display tab \u2192 Map view search distance limit<\/em>. <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"705\" height=\"361\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/s-d-l.png\" alt=\"\" class=\"wp-image-1964668\" srcset=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/s-d-l.png 705w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/s-d-l-300x154.png 300w\" sizes=\"auto, (max-width: 705px) 100vw, 705px\" \/><\/figure><\/div>\n\n\n<p>Then, it will give you the results found in your database and show the events happening at those venues on the front end.<\/p>\n\n\n\n<p>It can happen that you don&#8217;t get any results though, despite having venues in the search radius. Let&#8217;s look at the different request scenarios.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-results-of-the-api-request\">Results of the API request<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-the-provided-api-key-is-invalid\">The provided API key is invalid<\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"550\" height=\"127\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_key_invalid.jpg\" alt=\"\" class=\"wp-image-1959291\" srcset=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_key_invalid.jpg 550w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_key_invalid-300x69.jpg 300w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/figure><\/div>\n\n\n<p style=\"padding-top:0;padding-right:0;padding-bottom:0;padding-left:0\">The error message speaks for itself: the key is an invalid one. <\/p>\n\n\n\n<p style=\"padding-top:0;padding-right:0;padding-bottom:0;padding-left:0\">Solution: check if you have copied and pasted your API key correctly.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-this-api-key-is-not-authorized\">This API key is not authorized &#8230;<\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"550\" height=\"127\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_key_not_authorized.jpg\" alt=\"\" class=\"wp-image-1959298\" srcset=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_key_not_authorized.jpg 550w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_key_not_authorized-300x69.jpg 300w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/figure><\/div>\n\n\n<p>There can be some variations to this message depending on the exact issue.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>This API key is not authorized to use this service or API.<\/li>\n\n\n\n<li>This IP, site, or mobile application is not authorized to use this API key. Request received from IP address xxx.xxx.xxx.xxx, with empty referer<\/li>\n<\/ul>\n\n\n\n<p>The reasons can be:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The API key entered under <em>Events \u2192 Settings \u2192 Integrations<\/em> is the default API key that comes with Events Calendar Pro (<a href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/setting-up-your-google-maps-api-key\/#why\">which doesn&#8217;t support location search<\/a>).<br>Solution: <a href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/setting-up-your-google-maps-api-key\/\">set up your custom API key<\/a>.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If you have set up your custom API key, then the Geocoding API has not been enabled for this API key.<br>Solution: go to <a href=\"https:\/\/console.cloud.google.com\/google\/maps-apis\/api-list\" target=\"_blank\" rel=\"noreferrer noopener\">Google Cloud Console<\/a> and ensure you have the Geocoding API enabled for the API key.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The API key used for Geocoding is restricted, and the request comes from a website, application, or IP address that is not on the allowed list.<br>Solution: Check the IP address restrictions for the Geocoding API key. Please also check our <a href=\"https:\/\/theeventscalendar.com\/extensions\/google-maps-api-key-restrictions\/\" target=\"_blank\" rel=\"noreferrer noopener\">related article<\/a> on how to set up restrictions for your API keys correctly.<\/li>\n<\/ul>\n\n\n\n<p><em>Note: When someone runs a search on your website, the request to the Google Maps API will go from the IP address of the server where your website is hosted. When you are running requests via a URL in your browser, the request goes from the IP address of your device.<\/em><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-api-keys-with-referer-restrictions-cannot-be-used-with-this-api\">API keys with referer restrictions cannot be used with this API<\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"550\" height=\"127\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_key_restricted.jpg\" alt=\"\" class=\"wp-image-1959299\" srcset=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_key_restricted.jpg 550w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_key_restricted-300x69.jpg 300w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/figure><\/div>\n\n\n<p>The restrictions for the Geocoding API key are not set up correctly.<\/p>\n\n\n\n<p>Solution: Check the IP address restrictions for the Geocoding API key. Please also check our <a href=\"https:\/\/theeventscalendar.com\/extensions\/google-maps-api-key-restrictions\/\" target=\"_blank\" rel=\"noreferrer noopener\">related article<\/a> on how to set up restrictions for your API keys correctly.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-zero-results\">Zero results<\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"550\" height=\"99\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_zero_result.jpg\" alt=\"\" class=\"wp-image-1959300\" srcset=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_zero_result.jpg 550w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_zero_result-300x54.jpg 300w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/figure><\/div>\n\n\n<p>There are two main reasons for getting a response with zero results.<\/p>\n\n\n\n<p>The API didn&#8217;t find any matches for the search phrase.<\/p>\n\n\n\n<p>Or the API found <strong>too many<\/strong> results for the search phrase.<\/p>\n\n\n\n<p>A good example of this would be searching for &#8220;Springfield,&#8221; a common and popular name for municipalities in various states in the US. Also, there are more than a handful of <a href=\"https:\/\/www.google.com\/maps\/search\/Springfield\/@51.72309,-3.1632462,5.58z?entry=ttu\" target=\"_blank\" rel=\"noreferrer noopener\">results<\/a> for it in Europe in the form of cities and different retail stores.<\/p>\n\n\n\n<p>So, even if you have multiple venues in Springfield on your site, the location search will not return any results because the Google Maps API could not return an unambiguous result. <\/p>\n\n\n\n<p>Solution: provide more details in the search. <\/p>\n\n\n\n<p>(Some tweaks might work; check them out below.)<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-wrong-result\">Wrong result<\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"550\" height=\"220\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_wrong_result.jpg\" alt=\"\" class=\"wp-image-1959311\" srcset=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_wrong_result.jpg 550w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_wrong_result-300x120.jpg 300w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/figure><\/div>\n\n\n<p>Let&#8217;s imagine I live in a town called Crieff in the UK. I want to go out on Friday night, but there&#8217;s nothing happening here, so I search for the nearest bigger town with some action: <a href=\"https:\/\/maps.app.goo.gl\/snkZgGbRQdpyHtqP9\" target=\"_blank\" rel=\"noreferrer noopener\">Perth<\/a>. So I type &#8220;Perth&#8221; in the location search box and get results for&#8230; Australia.<\/p>\n\n\n\n<p>Obviously, Perth, Australia, is a bigger place than Perth, UK, and likely more popular, too, so likely that is why that comes up as a result. But that will not show anything on the calendar I can use.<\/p>\n\n\n\n<p>Again, the solution is to provide more details in the search term and search for &#8220;Perth, UK.&#8221; Alternatively, using some tweaks.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-multiple-results\">Multiple results<\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"550\" height=\"464\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_multiple_results.jpg\" alt=\"\" class=\"wp-image-1959306\" srcset=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_multiple_results.jpg 550w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_multiple_results-300x253.jpg 300w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/figure><\/div>\n\n\n<p>In this example, we use the popular city of Springfield again and try to narrow the search. The search phrase &#8220;Springfield, US&#8221; already gives us a smaller set of results, three cities in this case, with three different latitude and longitude coordinates.<\/p>\n\n\n\n<p>This, however, is still not good. How are we &#8211; or The Events Calendar &#8211; supposed to know where to search exactly?<\/p>\n\n\n\n<p>Just like before, your site will not be able to show you any results. Location search is geared towards a single location and the search radius around that. <\/p>\n\n\n\n<p>Solution: Providing more details in the search can help here, too.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-one-result\">One result<\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"550\" height=\"262\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_one_result.jpg\" alt=\"\" class=\"wp-image-1959307\" srcset=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_one_result.jpg 550w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_one_result-300x143.jpg 300w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/figure><\/div>\n\n\n<p>We go one step further and add the state to our search term: we&#8217;re looking for &#8220;Springfield, IL.&#8221; This is already specific enough for the Google Maps API, and it returns only one result. This is where the location search on the calendar can succeed.<\/p>\n\n\n\n<p>The site takes the coordinates, and with the help of a sophisticated algorithm, it will run a search within the set search radius.<\/p>\n\n\n\n<p>Once we have the venues, we can look up the events happening at those in the given timeframe, and we can show them on the selected calendar view.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2>\n\n\n\n<p>As you can see from the above, when doing a location search, you will only get results in the calendar if the Google Maps API can return one, and only one answer, as the result. <\/p>\n\n\n\n<p>The Google Maps API powers the location search, and it&#8217;s worth noting that we don&#8217;t have any influence over how the API itself works. We could say that the Google Maps API is a picky tool. In the end, it is &#8220;only&#8221; a machine which tries to do the best it can with the given data. It cannot guess what the user thinks. At least not yet.<\/p>\n\n\n\n<p>The only influence we have is the search term that is sent to the API. While we cannot tell users how exactly to search to get the intended results, we do have the possibility to alter the search term based on our needs slightly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-tweaks\">Tweaks<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-instruct-users\">Instruct users<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-add-a-tooltip\">Add a tooltip<\/h4>\n\n\n\n<p>If you have tested your location search and you found an approach that works, you can share it with your visitors as a tip. For example, you can add a short sentence below the search bar with this snippet.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;?php\nadd_action( \n\t&#039;tribe_template_after_include:events\/v2\/components\/events-bar&#039;, \n\tfunction( $file, $name, $template ) {\n\t\techo &#039;&lt;div style=&quot;margin-top: -32px; margin-bottom: 32px; text-align:center; width: 100%; font-style: italic;&quot;&gt;&#039;;\n\t\techo &#039;When searching for a location, add the state after the city name. E.g. Springfield, MI.&#039;;\n\t\techo &#039;&lt;\/div&gt;&#039;;\n\t}, \n\t10, \n\t3 \n);\n<\/pre><\/div>\n\n\n<p>This is how that would look like on the front end:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"272\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_snippet_example.jpg\" alt=\"\" class=\"wp-image-1959313\" srcset=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_snippet_example.jpg 1200w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_snippet_example-300x68.jpg 300w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_snippet_example-1024x232.jpg 1024w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_snippet_example-768x174.jpg 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<p><em>Check out our article about best practices <a href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/best-practices-for-implementing-custom-code-snippets\/\" target=\"_blank\" rel=\"noreferrer noopener\">Using Custom Code Snippets<\/a>, and the one about <a href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/template-hooks\/\" target=\"_blank\" rel=\"noreferrer noopener\">Template Hooks<\/a>. You might also find the article <a href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/using-template-filters-and-actions\/\" target=\"_blank\" rel=\"noreferrer noopener\">Using Template Filters and Actions<\/a> helpful.<\/em><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-change-the-placeholder-text\">Change the placeholder text<\/h4>\n\n\n\n<p>You can change the &#8220;In a location&#8221; placeholder text with a template override.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Take this file: <code>wp-content\/plugins\/events-calendar-pro\/src\/views\/v2\/location\/form-field.php<\/code><\/li>\n\n\n\n<li>Make a copy of it here: <code>wp-content\/themes\/[your-theme]\/tribe\/events-pro\/v2\/location\/form-field.php<\/code><\/li>\n\n\n\n<li>Adjust line 29, where you can find the placeholder string.<\/li>\n<\/ol>\n\n\n\n<p>This is the result:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"195\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_placeholder_example.jpg\" alt=\"\" class=\"wp-image-1959315\" srcset=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_placeholder_example.jpg 1200w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_placeholder_example-300x49.jpg 300w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_placeholder_example-1024x166.jpg 1024w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/01\/ecp_location_search_placeholder_example-768x125.jpg 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<p>If you&#8217;re using the calendar in a language other than English, then you can change the placeholder text through translations. (And actually, you can do that in English as well.)<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-localize-your-google-maps\">Localize your Google Maps<\/h3>\n\n\n\n<p>By default, Google Maps sets the locale to US-based locations. Fortunately, it is easy to change that and can help in certain scenarios. (For example, the one with Perth, UK.) Please refer to the article <a href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/change-the-google-maps-localization-option\/\">Change the Google Maps Localization Option<\/a> for details.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-tweak-the-search-phrase\">Tweak the search phrase<\/h3>\n\n\n\n<p>We cannot expect the customers to know how to get the best results with location search. But we can aid them with a little tweak. This can be useful if all your venues are in the same state, country, or area.<\/p>\n\n\n\n<p>This snippet will add a predefined string &#8211; &#8220;TX&#8221; &#8211; after the search phrase before it is sent to the Google Maps API. So, when someone types in &#8220;Atlanta,&#8221; the search phrase will be tweaked, and &#8220;Atlanta, TX&#8221; will be sent to the API.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;?php\nadd_filter( &#039;tec_google_map_args&#039;, &#039;tec_limit_search_to_texas&#039; );\n\nfunction tec_limit_search_to_texas( $args ) {\n\t$args&#x5B;&#039;address&#039;] = $args&#x5B;&#039;address&#039;] . &quot;, TX&quot;;\n\treturn $args;\n}\n\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>Events Calendar Pro offers the ability to perform smart location-based searches when filtering calendar events. This article aims to provide insight into how location search works in the background through the Google Maps API. If you&#8217;re interested in how to use location search, then head over to this article. This requires Events Calendar Pro to&#8230;<\/p>\n","protected":false},"author":17,"featured_media":1955565,"comment_status":"open","ping_status":"open","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":[123,61,1],"tags":[225,42,224],"stellar-product-taxonomy":[158],"class_list":["post-1959290","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-google-maps","category-events-features","category-uncategorized","tag-api","tag-google-maps","tag-location-search","stellar-product-taxonomy-events-calendar-pro"],"acf":[],"taxonomy_info":{"category":[{"value":123,"label":"Google Maps"},{"value":61,"label":"Product Features"},{"value":1,"label":"Uncategorized"}],"post_tag":[{"value":225,"label":"API"},{"value":42,"label":"Google Maps"},{"value":224,"label":"location search"}],"stellar-product-taxonomy":[{"value":158,"label":"Events Calendar Pro"}]},"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":123,"name":"Google Maps","slug":"google-maps","term_group":0,"term_taxonomy_id":123,"taxonomy":"category","description":"","parent":61,"count":5,"filter":"raw","term_order":"0","cat_ID":123,"category_count":5,"category_description":"","cat_name":"Google Maps","category_nicename":"google-maps","category_parent":61},{"term_id":61,"name":"Product Features","slug":"events-features","term_group":0,"term_taxonomy_id":61,"taxonomy":"category","description":"","parent":0,"count":31,"filter":"raw","term_order":"0","cat_ID":61,"category_count":31,"category_description":"","cat_name":"Product Features","category_nicename":"events-features","category_parent":0},{"term_id":1,"name":"Uncategorized","slug":"uncategorized","term_group":0,"term_taxonomy_id":1,"taxonomy":"category","description":"","parent":0,"count":139,"filter":"raw","term_order":"0","cat_ID":1,"category_count":139,"category_description":"","cat_name":"Uncategorized","category_nicename":"uncategorized","category_parent":0}],"tag_info":[{"term_id":225,"name":"API","slug":"api","term_group":0,"term_taxonomy_id":225,"taxonomy":"post_tag","description":"","parent":0,"count":5,"filter":"raw","term_order":"0"},{"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":224,"name":"location search","slug":"location-search","term_group":0,"term_taxonomy_id":224,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw","term_order":"0"}],"_links":{"self":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1959290","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=1959290"}],"version-history":[{"count":17,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1959290\/revisions"}],"predecessor-version":[{"id":1964670,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1959290\/revisions\/1964670"}],"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=1959290"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=1959290"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=1959290"},{"taxonomy":"stellar-product-taxonomy","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/stellar-product-taxonomy?post=1959290"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}