Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Maps - Trigger Search Box on button click
    text
    copied!<p>I'm interested in implementing a Google Maps search button with a 'Submit'/'Go' button next to it (such as on <a href="http://maps.google.com" rel="noreferrer">http://maps.google.com</a>). Everything works great if I press Enter in the search box, but I have no idea how to force/submit the search using the button.</p> <p>Right now I have my code based on the example on: <a href="https://developers.google.com/maps/documentation/javascript/examples/places-searchbox" rel="noreferrer">https://developers.google.com/maps/documentation/javascript/examples/places-searchbox</a> . The most important part is that I'm using this for now:</p> <p>HTML:</p> <pre><code>&lt;div id="intro-search"&gt; &lt;input id="search-box" /&gt; &lt;button type="button"&gt;Submit!&lt;/button&gt; &lt;/div&gt; </code></pre> <p>JS:</p> <pre><code> // Listen for the event fired when the user selects an item from the // pick list. Retrieve the matching places for that item. google.maps.event.addListener(searchBox, 'places_changed', function() { // ... // Show the results on the map // ... } </code></pre> <p>I have no idea how to trigger the same thing on a button click.</p> <p>On another note, what is the difference between the <a href="https://developers.google.com/maps/documentation/javascript/reference#SearchBox" rel="noreferrer">SearchBox</a> and the <a href="https://developers.google.com/maps/documentation/javascript/reference#Autocomplete" rel="noreferrer">Autocomplete</a> controls? Don't they do the same thing?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload