• I’ve had a good look at the docs and don’t think I can see this anywhere. I’ve googled around the Google API too.

    Is there a way I can trigger the location search when a user clicks on a location in the auto-complete dropdown, so they don’t also have to click the search button? I’m not showing the other dropdowns or additional search fields and from a user point of view, you click your city in the dropdown list and then wonder why nothing happens.

    I expect just my own snippet of jQuery would do the trick if I could find out the event I need.

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tijmen Smit

    (@tijmensmit)

    So I had a quick look at the Google Autocomplete docs, and there’s event listener that you could use.

    But you will have to include it in the wpsl-gmap.js file ( and minify it to wpsl-gmap.min.js ).

    If you look at the code here, then you see.

    
    autocomplete.addListener('place_changed', function() {
    // run code.
    }
    

    Maybe it’s a good idea to make this functionality optional in the 2.3 update.

    Thread Starter Andy Macaulay-Brook

    (@andymacb)

    Thanks for the pointer – I’ll try it out and see if I can get it working with my theme code so I don’t modify the plugin at all.

    Thread Starter Andy Macaulay-Brook

    (@andymacb)

    Hi, My skills just aren’t up to seeing whether I could have accessed the right object from my theme JS, especially with the plugin code minified, so I reluctantly edited the plugin as you suggested.

    So adding:

    $( "#wpsl-search-btn" ).trigger( "click" );

    after line 200 of wpsl-gmap.js worked.

    So, yes please, if this could become an option within the plugin then that would be fantastic.

    • This reply was modified 7 years, 2 months ago by Andy Macaulay-Brook. Reason: Mark the code as code
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Trigger search with location dropdown’ is closed to new replies.