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

  1. Access the Experience Editor of the Coveo-powered search page you want to edit (see Inserting and Customizing a Search Interface Component).

  2. Locate the distance-resources placeholder located at the top of the search page.
  3. Click Add here to insert a CoveoDistanceResources component.

  4. In the Select a Rendering dialog, click the Distance Resources icon, and then click Select.

  5. In the Control Properties dialog:
    1. In the Basic Settings section, fill out the following fields:
      1. Latitude Field: The name of the field to use as the latitude for the distance query.
      2. Longitude Field: The name of the field to use as the longitude for the distance query.
      3. Geolocation Provider: The geolocation providers to use, in ascending order.

      4. Google API key: The Google API key to use for the Google Geolocation API provider.
      5. Units: The units to use for calculating the distance.

        For more information about any of the fields above, see our Distance Resources Component page.

    2. 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.

    3. Click OK.
  6. Save and publish your page.
  7. 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.