Skip Navigation

[Resolved] List view sorting by distance

This support ticket is created 5 years, 2 months 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by stephenA 5 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#1347725

Tell us what you are trying to do?
We have implemented the Toolset Map on a view using "by distance" features, which works as expected.
item 1) There is a requirement for the associated list of items needing to be sorted by distance not by post_title. (see example below)
Item 2) There is a requirement to show all markers on the map from the entire query not just the ones on current page when using pagination (when viewing page one, only markers for that page are displayed on the map)

What is the purpose?
Item 1) The end user is searching for a service from a specified location (zip/post code) and there could be 50 results. End user expectation is the closest location will be at the top of the list view. Sorting alphabetically is confusing and not addressing the user need. (if the furthest location begins with "A" it will be at the top of the list)

Item 2) The end user is wanting to see all queried service locations on the map.
(at the moment we are achieving this by removing pagination however this has a negative impact when there are a lot of results)

Is there a similar example that we can see? (example without pagination)

hidden link

#1347733

Hello,

Q1) There is a requirement for the associated list of items needing to be sorted by distance not by post_title.
Yes, it is possible, you can follow our document to sort Views result by distance:
https://toolset.com/documentation/user-guides/display-on-google-maps/filtering-and-ordering-map-markers-by-distance/

Section "Ordering Views by Distance"

Q2) There is a requirement to show all markers on the map from the entire query not just the ones on current page when using pagination

There isn't such kind of built-in feature within Views, for example, in the post view, there are 10 items in each pagination, the marker shortcode [wpv-map-marker] will be outputted 10 times, so in your map, it will display only 10 markers in the map.

In your case, you might consider to create two post views:
- Query all posts without pagination, output the map
- Query posts with pagination, output the post information in text.

#1347749

My issue is resolved now. Thank you!