Inserting and Customizing a Distance Resources Component Using the Coveo for Sitecore Legacy Search UI Framework
Inserting and Customizing a Distance Resources Component Using the Coveo for Sitecore Legacy Search UI Framework
Coveo for Sitecore 4.1 (November 2018)
You can filter your query results based on geolocation attributes.
Three components are available for this purpose:
Distance Facet Slider Component
Distance Facet Range Component
Distance Sort
To be able to use geolocation components and rule, you must first add the Distance Resources Component
to the page. This component calculates the distance between each item and the user, which is then used by all the distance components and rules to filter the query based on distance.
To insert a distance resources component in a search page
-
Access the Experience Editor of the Coveo-powered search page you want to edit (see Inserting and Customizing a Search Interface Component).
- Locate the
distance-resources
placeholder located at the top of the search page. -
Click Add here to insert a
CoveoDistanceResources
component. -
In the Select a Rendering dialog, click the Distance Resources icon, and then click Select.
- In the Control Properties dialog:
- In the Basic Settings section, fill out the following fields:
- Latitude Field: The name of the field to use as the latitude for the distance query.
- Longitude Field: The name of the field to use as the longitude for the distance query.
-
Geolocation Provider: The geolocation providers to use, in ascending order.
- Google API key: The Google API key to use for the Google Geolocation API provider.
-
Units: The units to use for calculating the distance.
For more information about any of the fields above, see our Distance Resources Component page.
-
Depending on your needs, you may also want to change the value of the Distance Field Name, which represents the name of the field where the distance is stored on each item. The Distance Resources Component page has more information on the subject.
- Click OK.
- In the Basic Settings section, fill out the following fields:
- Save and publish your page.
- The distance components and rules may now be added to the search page and filter results based on the user’s geolocation.
What’s Next?
You may want to take a look at Inserting and Customizing a Sort Component, Inserting and Customizing a Facet Component and Adding Filtering or Boosting Expressions, which all have a variation based on the user geolocation, often tagged with “Distance”.
For more in-depth information on any of the distance component, see our List of Available Components.