1

We have a custom search page that uses the default components (search results, results count, and page selector) along with the custom location finder (Location search box + services dropdown + distance dropdown). We want to trigger the search on the button click (JS) along with the search box functionality (shipped default). On the button click, we need to perform the following

  1. Generate the geo-coordinates for the address entered.
  2. Create hash parameters based on the geo codes and other filter dropdown and update the URL.
  3. Trigger the search call to render the results.

Note: We do not want to use a facet filter.

Can someone guide us to achieve this?

1 Answer 1

1

Look like you are looking for the ready solution:) As far as I remember I already guide you to some scripts where we are generating the hash parameters.

  1. generate the geo-coordinates for the address entered - we are using typeahead plugin in the Location Finder to show some suggestions base on the location name entered by the user. So you can either use this or you can pass the text entered by the user to the XA.connector.mapsConnector.addressLookup() function and update the hash with the results
  2. create hash parameters based on the geo codes and other filter dropdown and update the url - I've already told you how to do that. Take a look at updateHash() function in component-search-location-filter.js. It does all that you need.
  3. trigger the search call to render the results - search will be triggered automacitally when you will update the hash (using e.g.: XA.component.search.query.updateHash function).
3
  • :D, thanks. I'm giving a try Commented Aug 8, 2019 at 14:01
  • Thank you Dawid. That worked. For somereasons addressLookup() returns undefined. For now I called the geocode service to get the coordinates. I need to look why that happens. Commented Aug 8, 2019 at 18:03
  • Endure that valid Google Maps JavaScript API key in your site. Commented Aug 8, 2019 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.