Instantsearch.js + Places

Are there any javascript examples of how to sync up instantsearch.js with Places? I’ve looked around, but no luck finding anything.

My use case: use instantsearch to search through a list of products and use Places as a filter to narrow down results by location. They can be used independently of one another.

Example: LinkedIn Job Search.


Correct me if I don’t understand your use case correctly.

  1. You’d have two fields:
  • one address field where places would be used and return address information
  • one product field that would interact with an index through the instantsearch.js library
  1. You want the location entered in the address field to restrict the product search.

Is that correct?

If so, you could try to have a state representing the location, and this state would be updated through the events that places emits. (all results will have a _geoloc field that encodes the latitude and longitude of the address) You can find more about this here:

Then you could use the coordinates you saved in the state to restrict the query in instantsearch using the aroundLatLng parameter (you can also set an aroundRadius value if you want to). You can find more about this parameter and how to use it in instantsearch.js here:

Here’s an old demo that uses some of these concepts together:

1 Like

Have a similar implementation here: