Skip Navigation

[Resolved] Distance value not working after categories filter

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a map View that shows markers and a list of results. If I change the category filter, the distance values disappear for the next set of results.

Solution: In this case, the map marker shortcode should be placed inside the wpv-loop tags, and repeated for each wpv-item. Use the wpv-post-id shortcode to make the marker ID dynamic.

<!-- wpv-loop-start -->
 
<div class="mapparisultati">[wpv-map-render map_id="map-19" map_height="450" map_type_control="off" cluster="on" spiderfy="on" street_view_control="off" marker_icon="//www.radiogoupon.com/wp-content/plugins/toolset-maps/resources/images/markers/Shop-2.png" style_json="//www.radiogoupon.com/wp-content/plugins/toolset-maps/resources/json/Standard.json"][/wpv-map-render] </div>
 
<wpv-loop wrap="3" pad="true">
[wpv-item index=1]
[wpv-map-marker map_id='map-19' marker_id='marker-[wpv-post-id]' marker_title='[wpv-post-title]' marker_field='wpcf-localizzazione']<a href="#[wpv-post-id]">[wpv-post-title] [toolset-maps-distance-value origin_source='url_param' postmeta='wpcf-localizzazione'] km da te<br>[types field='localizzazione'][/types]</a>[/wpv-map-marker]
<div class="riga-cou">
<div class="col-sm-4">[wpv-post-body view_template="loop-item-in-vedi-sconti-su-mappa-test"]</div>
[wpv-item index=other]
[wpv-map-marker map_id='map-19' marker_id='marker-[wpv-post-id]' marker_title='[wpv-post-title]' marker_field='wpcf-localizzazione']<a href="#[wpv-post-id]">[wpv-post-title] [toolset-maps-distance-value origin_source='url_param' postmeta='wpcf-localizzazione'] km da te<br>[types field='localizzazione'][/types]</a>[/wpv-map-marker]
<div class="col-sm-4">[wpv-post-body view_template="loop-item-in-vedi-sconti-su-mappa-test"]</div>
[wpv-item index=3]
[wpv-map-marker map_id='map-19' marker_id='marker-[wpv-post-id]' marker_title='[wpv-post-title]' marker_field='wpcf-localizzazione']<a href="#[wpv-post-id]">[wpv-post-title] [toolset-maps-distance-value origin_source='url_param' postmeta='wpcf-localizzazione'] km da te<br>[types field='localizzazione'][/types]</a>[/wpv-map-marker]
<div class="col-sm-4">[wpv-post-body view_template="loop-item-in-vedi-sconti-su-mappa-test"]</div>
</div>
<div class="riga-cou">
[wpv-item index=pad]
<div class="col-sm-4"></div>
[wpv-item index=pad-last]
<div class="col-sm-4"></div>
</div>
</wpv-loop>
 
<!-- wpv-loop-end -->
This support ticket is created 6 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 8 replies, has 2 voices.

Last updated by simoned-2 6 years ago.

Assisted by: Christian Cox.

Author
Posts
#1207426

Hi,

I would like to show in my results the distance in km from the value "my location".
this works only at the beginning, then if you click on the categories filter, the system loses the coordinates and the value "distance value" remains empty.
do I have to click on "my location" again to update?
What did I do wrong?
hidden link
Thank you

#1207869
Screen Shot 2019-02-28 at 12.58.44 PM.png

Hi, I just tested using a location near Roma and selected the Affrettati Per La Tua Vacanza category, and I am able to see distances appear in the map marker popups and in the search results. I'm attaching a screenshot here for your reference. Since I do not speak Italian, I might be missing something obvious. Can you help me understand the problem? If you are seeing something different in your search, please tell me your current location (city and country, or latitude and longitude) so I can test with that information. Tell me step-by-step how to search. Thank you for your help.

#1207929

hi,
the combined search between categories and location, works only if I insert a submit button. this does not work if I use ajax and auto update.
I have the same problem if I change the page. on the first page I see the distances, but in the second the value disappears

#1207939
page-2.jpg
page-1.jpg

screen shot

#1207965

Could you copy + paste the code from your Loop editor here for me to review? If any wpv-post-body shortcodes are used, please copy the code from those templates as well. I will take a look and update you shortly.

#1208192

ok:

search section

[wpv-filter-start hide="false"]
[wpv-filter-controls]
<div class="filtri">
<div class="row">
<div id="distanza" class="col-sm-12 filtrodistanza">
[wpv-control-distance default_distance="100" compare_field="localizzazione" distance_center_url_param="toolset_maps_distance_center" distance_radius_url_param="toolset_maps_distance_radius" distance_unit_url_param="toolset_maps_distance_unit"]

</div>
<!--<div class="col-sm-12"> <input id="filtracat" type="button" class="btn " value="Scegli per categoria" style="font: 14px/1 FontAwesome; display: inline;">-->

<div class=" menucat">
<div class="form-group">
[wpv-control-post-taxonomy taxonomy="categoria-coupon" type="select" default_label="Scegli la categoria" url_param="wpv-categoria-coupon"]
</div>
</div>
<!-- </div> -->
</div>

</div>
<div class="cont-invia">[wpv-filter-submit output="bootstrap" name="Mostra Offerte" class="inviaris"]</div>

[/wpv-filter-controls]
[wpv-filter-end]

Loop Section

[wpv-layout-start]
[wpv-items-found]

<!-- wpv-loop-start -->

<div class="mapparisultati">[wpv-map-render map_id="map-19" map_height="450" map_type_control="off" cluster="on" spiderfy="on" street_view_control="off" marker_icon="//www.radiogoupon.com/wp-content/plugins/toolset-maps/resources/images/markers/Shop-2.png" style_json="//www.radiogoupon.com/wp-content/plugins/toolset-maps/resources/json/Standard.json"][/wpv-map-render] </div>

<wpv-loop wrap="3" pad="true">
[wpv-map-marker map_id='map-19' marker_id='marker-23' marker_title='[wpv-post-title]' marker_field='wpcf-localizzazione'][wpv-post-title] [toolset-maps-distance-value origin_source='url_param' postmeta='wpcf-localizzazione'] km da te
[types field='localizzazione'][/types]
[/wpv-map-marker]
[wpv-item index=1]
<div class="riga-cou">
<div class="col-sm-4">[wpv-post-body view_template="loop-item-in-vedi-sconti-su-mappa-test"]</div>
[wpv-item index=other]
<div class="col-sm-4">[wpv-post-body view_template="loop-item-in-vedi-sconti-su-mappa-test"]</div>
[wpv-item index=3]
<div class="col-sm-4">[wpv-post-body view_template="loop-item-in-vedi-sconti-su-mappa-test"]</div>
</div>
<div class="riga-cou">
[wpv-item index=pad]
<div class="col-sm-4"></div>
[wpv-item index=pad-last]
<div class="col-sm-4"></div>
</div>
</wpv-loop>

<!-- wpv-loop-end -->
<div class="paginatore">

<span class="page-item">[wpv-pager-prev-page][wpml-string context="wpv-views"]Previous[/wpml-string][/wpv-pager-prev-page]</span>
<span>Pagina [wpv-pager-current-page] di [wpv-pager-total-pages] totali</span>
<span class="page-item">[wpv-pager-next-page][wpml-string context="wpv-views"]Next[/wpml-string][/wpv-pager-next-page]</span>

</div>
[/wpv-items-found]

[wpv-no-items-found]
[wpml-string context="wpv-views"]<div style="text-align: center; padding:10px;"><h4>Ci dispiace! Non ci sono offerte che corrispondono alla tua ricerca</h4></div>[/wpml-string]
[/wpv-no-items-found]
[wpv-layout-end]

view template
<div class="totale">
<div style=" background-color:#001d47;">
<div class="distance">
<h4>a [toolset-maps-distance-value origin_source='url_param' postmeta='wpcf-localizzazione'] km da te</h4>
</div>
<div class="informazioni">
<div class="categoria">[wpv-post-taxonomy type="categoria-coupon" separator="<br>" format="name"]</div>
<div class="zona">Zona: [types field='zona' item='@coupon-buono-sconto.child'][/types]</div>
</div>
</div>
<div id="[wpv-post-id]" class="titolo"><h4 >[wpv-post-title]</h4></div>
<p style="display:none;">[types field='indirizzo-attivita' item='@coupon-buono-sconto.child'][/types]</p>
[wpv-conditional if="( $(wpcf-tipo-annuncio) eq 'video' )"]
<div class="video">[types field="video-dello-spot"][/types]</div>
[/wpv-conditional]
[wpv-conditional if="( $(wpcf-tipo-annuncio) eq 'foto' )"]
<div class="video">[wpv-view name="galleria-foto-offerta"]</div>
[/wpv-conditional]
<div class="footer-ann">
<div class="valoresconto">
[wpv-conditional if="( $(wpcf-tipo-promozione) eq 'sconto' )"]
<div class="offerta">

<span class="intero">[types field='prezzo-intero'][/types]</span>
<span class="ridotto">[types field='prezzo-scontato'][/types]</span>

</div>
<div class="perc-calcolata">
<span> [types field='percentuale-risparmio'][/types]</span>
</div>
<div class="desc-sconto">
<span>[types field='descrizione-sconto'][/types]</span>
</div>

[/wpv-conditional]
[wpv-conditional if="( $(wpcf-tipo-promozione) eq 'fisso' )"]<span>[types field='valore-sconto-fisso' separator=', '][/types]</span>[/wpv-conditional]</div>
<!-- <div class="citta">Accedi all'Offerta</div>-->
<div class="citta">Scarica Coupon</div>
<div class="chat">hidden link field='telefono-attivita' separator=', ' item='@coupon-buono-sconto.child'][/types]" onClick="gtag('event', 'Chat', { event_category: 'ContattoInserzionista', event_label: 'WhatsApp'});"> <i class="fa fa-whatsapp">Chatta</div>
</div>
</div>

Now the search is set to start when user click on input button.
but i need to set in Ajax in future

#1209507

Okay let's change the loop a little bit. This will move the map marker shortcode inside the wpv-item shortcodes and make the marker ID dynamic:

<!-- wpv-loop-start -->

<div class="mapparisultati">[wpv-map-render map_id="map-19" map_height="450" map_type_control="off" cluster="on" spiderfy="on" street_view_control="off" marker_icon="//www.radiogoupon.com/wp-content/plugins/toolset-maps/resources/images/markers/Shop-2.png" style_json="//www.radiogoupon.com/wp-content/plugins/toolset-maps/resources/json/Standard.json"][/wpv-map-render] </div>

<wpv-loop wrap="3" pad="true">
[wpv-item index=1]
[wpv-map-marker map_id='map-19' marker_id='marker-[wpv-post-id]' marker_title='[wpv-post-title]' marker_field='wpcf-localizzazione']<a href="#[wpv-post-id]">[wpv-post-title] [toolset-maps-distance-value origin_source='url_param' postmeta='wpcf-localizzazione'] km da te<br>[types field='localizzazione'][/types]</a>[/wpv-map-marker]
<div class="riga-cou">
<div class="col-sm-4">[wpv-post-body view_template="loop-item-in-vedi-sconti-su-mappa-test"]</div>
[wpv-item index=other]
[wpv-map-marker map_id='map-19' marker_id='marker-[wpv-post-id]' marker_title='[wpv-post-title]' marker_field='wpcf-localizzazione']<a href="#[wpv-post-id]">[wpv-post-title] [toolset-maps-distance-value origin_source='url_param' postmeta='wpcf-localizzazione'] km da te<br>[types field='localizzazione'][/types]</a>[/wpv-map-marker]
<div class="col-sm-4">[wpv-post-body view_template="loop-item-in-vedi-sconti-su-mappa-test"]</div>
[wpv-item index=3]
[wpv-map-marker map_id='map-19' marker_id='marker-[wpv-post-id]' marker_title='[wpv-post-title]' marker_field='wpcf-localizzazione']<a href="#[wpv-post-id]">[wpv-post-title] [toolset-maps-distance-value origin_source='url_param' postmeta='wpcf-localizzazione'] km da te<br>[types field='localizzazione'][/types]</a>[/wpv-map-marker]
<div class="col-sm-4">[wpv-post-body view_template="loop-item-in-vedi-sconti-su-mappa-test"]</div>
</div>
<div class="riga-cou">
[wpv-item index=pad]
<div class="col-sm-4"></div>
[wpv-item index=pad-last]
<div class="col-sm-4"></div>
</div>
</wpv-loop>

<!-- wpv-loop-end -->
#1211862

perfect, I did not understand that the marker should go in every index.
now it works, thanks

#1211863

My issue is resolved now. Thank you!