Coveo for Sitecore 5 is now available!

DistanceResources

This component is used to define options and register events to resolve the distance between the user and the results.

Coveo for Sitecore 4.1 (January 2018)

Starting with the January 2018 release, this component has been directly integrated into the JavaScript Search Framework (see Coveo DistanceResources Component).

Options

distanceField

The name of the field that’s created with the computed distance.

This field is required.

The default value is undefined.

<div class="DistanceResources" data-distance-field='@distancefromuser'></div>

latitudeField

The name of the field used for the latitude.

This field is required.

The default value is undefined.

<div class="DistanceResources" data-latitude-field='@latitude'></div>

longitudeField

The name of the field used for the longitude.

This field is required.

The default value is undefined.

<div class="DistanceResources" data-longitude-field='@longitude'></div>

unitConversionFactor

The conversion factor to use for the distance according to the base unit, in meters.

If you want to have Kilometers, you should set 1000 as the value.

If you want to have your distance in miles, you should set 1610 as the value, since a mile is about 1610 meters.

The default value is 1000.

<div class="DistanceResources" data-unit-conversion-factor='1000'></div>

Events

onPositionResolved

Triggered when the position has been successfully resolved.

Use this to get the resolved position and use it on your site.

onResolvingPosition

Triggered when trying to resolve the position.

Use this to register custom position providers.

onPositionNotResolved

Triggered when the position has not been successfully resolved using the registered providers.

Use this if you want to show warnings to the user if the position is necessary.

Sample

<div class="CoveoDistanceResources"></div>
Recommended Articles