DigitalLawyer
DigitalLawyer

Reputation: 49

Display Algolia search results on map with only subset of results having _geoloc

I have an application that uses instantsearch.js by Algolia to render search results. The search results fall into 3 broad categories (people, articles, services). Only people have a _geoloc attribute associated with them.

I instantiate the search widget using:

var search = instantsearch({
  appId: 'xxx',
  apiKey: 'f9217ccdd8e1925a1823e00377e86235',
  indexName: 'dev_test_public_search'
});


search.addWidget(
      instantsearch.widgets.searchBox({
        container: '#q',
        placeholder: 'How can we help?'
      })
    );

I instantiate the map using:

search.addWidget(
  instantsearch.widgets.googleMaps({
    container: document.querySelector('#map'),
  })
);

When only people are returned as hits, the results render correctly on the map. However, when the dataset includes services or articles, I get the following error:

Uncaught RangeError: Maximum call stack size exceeded

I understand that this is due to the fact that no _geoloc is present for the hits of type services / articles.

Is it possible to only render a subset of hits on the map?

Upvotes: 1

Views: 237

Answers (1)

Josh Dzielak
Josh Dzielak

Reputation: 1823

I don't believe there's a way to filter the results right now, but really this should be protected against inside of the instantsearch-googlemaps widget. I've opened an issue to that effect.

Upvotes: 1

Related Questions