Hello,
I'm searching for a option to sort custom posts by distance to the given location by the user.
At the current situation just all the posts show up but there is no logical order in this for the user if he searches on a location.
I can see that there some other directory plugins out there for wordpress which support this, but I don't want to use other plugins since Toolset is so much easier.
Could you guys implement an custom post sorting for distance?
For example if the user doesn't uses his location but enters a city name, I would like to use the center of the city to start measuring the distance.
I've read on the forums about an guy that made a custom tool for this, so it's not impossible. I think if you implement a feature like this, the maps tool is so much more attractive to use.
Would like to hear form you guys about this!
Distance is not a sort option, it is a Custom Search / Query Filter option.
Sorting by a distance would assume that you have a Center, a Distance and a Unit to measure by.
Those things are not available in a simple order option, where we get one value (usually a string or number) and sort it (usually numerically or alphabetically, asc or desc).
I have filed a request that practically asks to allow to order/sort by the address as a distance to some given point, and added your voice to it.
I cannot estimate whether this will or when it will be implemented.
You can follow the blog posts and changelogs, to get notified in case we implement this in future.
Sorting by a distance would assume that you have a Center, a Distance and a Unit to measure by.
Yes exactly the user provides the Center (city), the distance would be measured in km (in my case) to the locations that are available.
When you only enter a city name in google maps it sets to the center of it, so Google always takes a center point of something you search for. I think this could be used to set the Center?
-
Since this option is not available (yet) what would you suggest to get the most accurate sorting?
I don't want users to find places on top of the list that are the newest added but relative far away of their location.
When using a mobile the screen has a small display, so the first few items should be the most relevant to the user.
When I would set the distance rage to 0 the user will find the locations in the city they searched for. But it will happen that they search for a city with no locations available, so the result would be nothing.. So that's why the minimum range would be 15km for example, this will prevent no results and headache to a user.
As I wrote in my first message, there are plugins out there that can do what I need. But would those be compatible with Toolset? For the time Toolset doesn't support this kinda feature I'm looking for alternatives or tricks to make this kinda work.
With Toolset, you can do that right now only thru a Custom Search.
This means the visitor needs to filter.
I do not know of other plugins doing that and being compatible with Toolset, especially because using 2 Google Maps solutions (hence a double key API etc) is not possible and will cause issues, hence you would at least have to disable either of both "google maps" software.
Since it's not possible the way you want with Toolset, yet, I suggest to use those other plugins you mention.
Both together (Toolset MAPS and another Maps service) will cause issues.
With Toolset, you can do that right now only thru a Custom Search.
This means the visitor needs to filter.
So you mean I need to setup the search trough relevanssi? Is relevanssi compatible with the address field?
Could you maybe point me some directions to make this work for me with custom search?
I don't know exactly where to start and how to set this up.
Toolset Maps adds an Address Field.
Once you save some posts with this address field, in a View, you can query those pots and display the posts on Maps:
https://toolset.com/documentation/user-guides/display-on-google-maps/
You can also search thru those addresses, either by address or by the distance from:
https://toolset.com/2018/02/toolset-maps-features-in-reference-sites-viewing-geolocation-and-filtering-by-distance-in-action/
https://toolset.com/documentation/user-guides/display-on-google-maps/displaying-markers-on-google-maps/
Example:
hidden link
You do not need Relevannsi for this.