instantsearch with Angular - How to Geo search ?
See original GitHub issueHi! I’m using InstantSearch Service with Algolia V4 and it’s working !
Now I’d like to filter results via IP.
Details :
My index has an attribute called “perimetre” By default, I’d like to GEO filter all results depending on user IP
I found this : https://www.algolia.com/doc/tutorials/geo-search/filter-results-around-a-location/#filtering-around-the-current-user-location
How can I use this with Angular ? Can I configure this directly in my Algolia Dashboard or should I implemente it in my code ? How ?
This is my hits.component.ts :
export class HitsComponent implements OnInit {
// Define how your component state will look like,
// and intialize it with an empty hits array
state: { hits: {}[] } = { hits: [] };
nbResultToShow = 8;
constructor(private instantSearchService: InstantSearchService) { }
ngOnInit() {
// Create a widget which will call `this.updateState` whenever
// something changes on the search state itself
const widget = connectHits(this.updateState);
// Register the Hits widget into the instantSearchService search instance.
this.instantSearchService.search.addWidget(widget());
}
updateState = (state, isFirstRendering) => {
// asynchronous update of the state
// avoid `ExpressionChangedAfterItHasBeenCheckedError`
if (isFirstRendering) {
return Promise.resolve().then(() => {
this.state = state;
});
}
this.state = state;
}
}
Thanks !
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Geo search with Angular InstantSearch - Algolia
Leverage Geo search in your Angular InstantSearch app. ... We will see how we can leverage the geo search capabilities of Algolia with...
Read more >Using Algolia Instantsearch with Angular 6. | by Zev | Medium
Algolia provides a set of parameters for filtering by facets, numbers or geo location. Angular InstantSearch packages those into a set of ...
Read more >Algolia Angular InstantSearch buggy search-box
I was able to reproduce this behavior! It's related to the <ais-index indexName="index-name"> you have wrapping your hits component.
Read more >angular-instantsearch - npm
Lightning-fast search for Angular apps, by Algolia.. Latest version: 4.4.0, last published: 20 days ago. Start using angular-instantsearch ...
Read more >angular-instantsearch examples - CodeSandbox
Learn how to use angular-instantsearch by viewing and forking angular-instantsearch example apps on CodeSandbox. ... algolia-instantsearch-angular-geo.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hy @bobylito
Many thanks for your answer aroundLatLngViaIP is working !
How if I want to set the aroundRadius depending on data attribute ? I managed to set it in the service :
But then, it’s the same radius for all However, I have an attribute called “perimetre” for each hit. How can use it ?
I’ll have a look on your Angular beta link, looks awesome 😃
You can use the
ais-configure
widget to provide the location toaroundLatLng
.