This is a continuation of sorts from a previous support ticket (https://toolset.com/forums/topic/conditional-display-inside-of-a-for-each-based-on-map-distance/)
I am attempting to compare the individual values of a repeatable Address field against a map search radius. In the previous ticket, we determined that it's not possible to filter content within a for-each. And creating a repeatable field group is not a viable option for my users.
Further experimentation made it clear that there are a few limitations working against me:
- toolset-maps-distance-value can only compare the origin string against a dynamic destination.
- toolset-maps-distance-conditional-display compares a dynamic origin with a destination string.
- there is no built-in way to calculate the distance between an origin string and a destination string. Is there?
With the following view output, I was able to separate the repeatable address field into single values, and then compare that value against the user's location. This works great to eliminate results outside of the radius!
Except that it only works if the user is performing a search within the radius of their own location. hidden link
So my question is, can I set the value of the user's location detected in 'toolset-maps-distance-conditional-display' to always equal the search filter 'toolset_maps_distance_center'?
For instance, something like [wpv-geolocation location='toolset_maps_distance_center'][/wpv-geolocation]
<!-- wpv-loop-start -->
<wpv-loop>
<div id="item-[wpv-post-id]">
<!-- Declare a result within the search radius. -->
<h4>[wpv-post-body view_template="full-name"][wpv-post-body view_template="workshop-title"]</h4>
<p class="uk-text-meta">[toolset-maps-distance-value origin_source='url_param' postmeta='wpcf-address' unit='mi'] is less than [wpv-search-term param='toolset_maps_distance_radius']</p>
<!-- Use for-each to separate repeatable address field into individual address values. -->
[wpv-for-each field="wpcf-address"]
<!--
Use distance conditional to compare individual address value against the user's location and radius value.
This only works if the results from the search are also within the user's radius.
-->
[toolset-maps-distance-conditional-display location='[types field="address"][/types]' distance='[wpv-search-term param="toolset_maps_distance_radius"]']
<!-- individual addresses within user radius are displayed and create a marker -->
Hello. Thank you for contacting the Toolset support.
Can you please share admin access details and problem URL and tell me what is your expected result on that page.
As I understand - you want to use the current user's location as distance center?
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.