Skip to main content
Distance display and units

MetaLocator can display distance in KM and Miles and in custom formats

Michael Fatica avatar
Written by Michael Fatica
Updated over a week ago

When MetaLocator performs a distance-based search, the system can display that distance as part of the results. Users can also decide what units, such as kilometers or miles are used to display the results. This article discusses relevant options.

A distance based search is performed when MetaLocator compares one geographic point location to another. For example, between a user and a store or between a zip code and a dealer.

To display distance in the search results, add the Distance field to the List, if it is not already present:

The Format string uses a sprintf format to output the distance measurement. The first placeholder is the numerical distance, shown below as %d and the second is the unit of measurement shown below as %s. The distance can be formatted as decimal format as %.2f for two decimal places.

Example formats include:

%d %s away    |70 Miles away
%.2f %s |70.77 Miles
%.1f |70.8
%.1f %s |70.8 Miles
%.1fm |70.8m
%.1f miles |70.8 miles

Configure the format as shown below

Units of Measurement

Distance can be measured according to the Measure in kilometers or miles setting.
โ€‹

The units of measurement can also be automatically detected based on the country associated with the visitor's IP address. This distance unit is selected based on the user's detected country, which may differ from the search the user is performing. E.g. if I am personally in Germany, a country that uses KM to measure distance, all of my searches will measure in KM, even my searches in the United States, where Miles are the native unit.

Finally MetaLocator also offers the ability to allow users to select the distance unit as part of their search as shown below. To add this option, click Search Form, Add Field, select Distance Unit and arrange as shown below.

Exceptions

Not all searches are distance based. In those cases distance will not display. For example, "dealers in Argentina" finds all dealers in Argentina and does not measure the dealer's distance from a given point. Additionally, some territory searches are not distance based. E.g. "dealers that service Argentina" may include dealers well outside of Argentina.

Did this answer your question?