Saltar navegación

[Esperando confirmación del usuario] How to let the user enter distance radius

This support ticket is created hace 5 días, 1 hora. 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Este tema contiene 12 respuestas, tiene 1 mensaje.

Última actualización por Minesh hace 2 horas, 59 minutos.

Asistido por: Minesh.

Autor
Mensajes
#2808459
location.jpg

Hello,
Please help me to find a way to let the user select the filter distance radius. I don't get how to add this filter to my map, I just need to let the user enter or select a distance radius always from the user position and Km only. Both for block map and classic map. See picture.
Thanks
Regards
Nicola

#2808592

Minesh
Colaborador

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I'm not sure if you are using a block view or legacy views.

Howver - here is the doc that shows all informationl.
- https://toolset.com/course-lesson/filtering-and-ordering-map-markers-by-distance/

For legacy views:
- https://toolset.com/documentation/legacy-features/maps-plugin/filtering-and-ordering-map-markers-by-distance/

Please let me know if you require further assistance.

#2808596

Hello Minesh,
thanks for replying. I wrote to you because I did read those docs, but I couldn't understand why I must set "Should distance center input be required" value to No while I do have other filters active an I should select Yes ? Why can't all filters work together ? also I'm currently using "Distance center is set from user location", I don't understand why it seems I have to use "Distance center is set using URL parameters" instead ....
What am I missing ?
thanks
Regards
Nicola

#2808603

Minesh
Colaborador

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

It's already stated when you select No:

No (use when combining this filter with others)

So, you should select "No" option.

What filters are not working togather?

Can you please share problem URL and admin access details as well as what is your expected results?

*** 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.

#2808612

Minesh
Colaborador

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

When I checked the following page loggedin as admin user:
=> enlace oculto

I do not see the view you mention. When I checked the page in backend:
=> enlace oculto

I noticed that you display the view based on some conditions.

Do I require frontend user access details? if yes:

Can you please share frontend user access details.

I have set the next reply to private which means only you and I have access to it.

#2808614

In the editor you find the view in the second conditional.
On frontend the page works fine, but you probably cannot see anything because of the active geolocation, there are no profiles to display in your part of the world. You can change the address of this profile to any address close to you so that you might then show it on the map
enlace oculto

#2808615

Minesh
Colaborador

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Well - I see the view is set to display the post type "Profili" posts.
=> enlace oculto

I'm not sure what address field I should change. Can you pleased tell me what address field I should change on user profile page?

#2808622

Apologise, you are right, use this PROFILE:
enlace oculto

#2808785

Minesh
Colaborador

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

As you can see I've updated the address with the profile post you shared:
- enlace oculto

But I do not see view on frontend. Can you please tell me what view I should check against as there are multiple views added on the page.

#2808801

Yes, I can see your address in Paralyzed profile. You should now go to :
enlace oculto
and you should see a map with the Paralysed Icon located to your address in India.
Can you ?

#2808925

Minesh
Colaborador

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Yes - I added the address but yet I do not see the map on the page.

#2808939

ok, I don't know why, I can. However my question was not about the map itself, but about how to add the distance filter that can be set by the user in order to let him change the distance radius from his position, any clue ?

#2809103

Minesh
Colaborador

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

I've created the following view and added the distance filter to it:
=> enlace oculto

I've setup a test page and added the above view as given under:
=> enlace oculto

[wpv-geolocation]
[wpv-view name="toolset-distance-search-user-location"]
[/wpv-geolocation]

We have wrapped the view "toolset-distance-search-user-location" within the shortcode [wpv-geolocation] so the reults will display once user allow his current location address and that way we will be able to get the user's current location.

Then I've added the following code to "Custom Code" section offered by Toolset with the code snippet namely "toolset-custom-code":
=> enlace oculto

add_filter( 'wpv_view_settings', 'func_show_results_within_user_current_location', 10, 2 );
function func_show_results_within_user_current_location( $view_settings, $view_id ) {

  if (   $view_id ==  29802  ) { 
     
      $user_location_lat_lon = $current_user_lat = $current_user_lon = 0;
    
      /// get current location of user
      if(isset($_COOKIE["toolset_maps_location"]) and $_COOKIE["toolset_maps_location"]!=''){
        	$user_location_lat_lon = explode(",",$_COOKIE["toolset_maps_location"]);
        	$current_user_lat = $user_location_lat_lon[0];
            $current_user_lon = $user_location_lat_lon[1];
      }
      
       if ( ! empty( $user_location_lat_lon ) ) {
           
                 $view_settings['map_distance_filter']['map_center_lat'] = $current_user_lat;
                 $view_settings['map_distance_filter']['map_center_lng'] = $current_user_lon;
                }
          
            }
        return $view_settings;
}

Now, when I check on frontend, it does only show one entry that is belongs to my location.
=> enlace oculto

More info:
- https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#wpv-geolocation
- https://toolset.com/documentation/programmer-reference/views-filters/#wpv_view_settings