Hi, I need your help how to display distance value (km) from a user's current location to a main clinic location?
Here is the page I work on: hidden link
If I enter my location on the field (only with Australia), the location lists showing and the DISTANCE value showing up per clinics how far from thier current location to the clinic location.
Ideally, I need the user to see all closest clinics in order of closest to furthest with the distance shown on the results if possible
See attached screenshot below.
Hi,
Welcome to Toolset support.
Please follow the steps below:
1) View setup (Clinics)
- Edit the View that lists your Clinics (the CPT holding the clinic address field).
- Add a Distance filter:
. Source: Visitor location (for geolocation) or Address entered by the user (if you’re using a location input).
. Units: Kilometers.
- In Ordering, set Order by distance (ascending) using the same Address field as the “Post address.” This makes the list nearest → farthest.
For more information:
https://toolset.com/course-lesson/filtering-and-ordering-map-markers-by-distance/
2) Show the distance in the Loop
In the View’s Loop (next to each clinic), output the distance value with the Maps shortcode. Use one of these, depending on how you’re determining the center:
A) From the visitor’s current location (browser prompt)
[toolset-maps-distance-value origin_source="visitor" postmeta="wpcf-clinic-address" unit="km" decimals="1"] km
B) From the front-end distance controls (address/radius inputs)
[toolset-maps-distance-value origin_source="url_param" postmeta="wpcf-clinic-address" unit="km" decimals="1"] km
Replace wpcf-clinic-address with your clinic Address field slug. (The decimals attribute rounds the number neatly.) Full shortcode reference here:
https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#toolset-maps-distance-value
Thanks.