I am trying to add a distance filter (like where you type in and it suggest and address and you set it and say "20km within") and I cant - simply the filter does not offer a distance option?
I CAN add a _types and fields_ shortcode to show the distance... I CAN add the map... but not the filter itself?
I do have a valid address field and I am tried both with google and OpenStreetmaps.
Welcome to Toolset support. Would you please follow the steps below to create a distance filter?
A. Add the Query Filter first:
- Edit your View → Query Filter → Add a filter → choose Distance (filter by distance from an origin).
- Select your Address field and units (km/mi).
- Set the origin to be provided by URL parameters (e.g. center and radius) or by shortcode attributes. Save.
B. Add the search control:
- Now go to Search and Pagination → Insert a custom search filter and type “distance”.
You’ll see the control once the Query Filter exists.
- Typical shortcode the dialog inserts (you can paste this manually if you prefer):
[wpv-control-distance
url_param_center="center"
url_param_distance="radius"
distance_units="km"
default_distance="20"
placeholder="Enter a city or address"]
[wpv-submit name="Search"]
If you didn’t add the Query Filter in step A, the “Distance” control won’t be offered in this dialog.
Hi Christopher, when did this change? I am fairly positive this was never a requirement to first add a query filter, then an actual front end filter.
In any case, I cannot see any location filter other than my location custom field, which when added, does not offer any of the required options for actual distance filtering.
See attached screenshots.
This is a classic View, all Plugins, inclusive toolset maps, are up to date.
What's even weirder is if I add the shortcode you proposed to the filter, I cannot even see that filter (and it should show, even if the Query filter where removed/not present, because well, a shortcode always expands to something)
I'd appreciate it if you could give me the URL/User/Pass of your WordPress dashboard after you make sure that you have a backup of your website.
It is absolutely important that you give us a guarantee that you have a backup so if something happens you will have a point of restore.
Thank you I logged in and found out that you tried with Openstreet. What you see is the expected results as OpenStreetMaps does not support geolocation-based distance filters (e.g., within X km of an address).
Can you change it to Google Maps and add the proper API Keys so it will be available and then test?
Well, indeed it works with Google - but following https://toolset.com/course-lesson/creating-a-maps-api-key/, it literally says:
> Prefer not to create an API key?
>
> If you prefer not to create an API key, you can use OpenStreetMap with Toolset Maps. OpenStreetMap requires no account, no billing setup, and no API key. You can start building maps right away.
I cannot find any documentation saying that using OpenStreeMap this will be a crippled feature, even the GUI in Toolset Settings says:
> Select the API to be used for maps rendering, geolocation and other functionalities of this plugin.
Not a word on the basically fairy "useless" feature of OpenStreetMaps (yes, I know you can still show a map using this - but honestly, that is an extremely narrowed down and edge use case. If we have locations, the next logical step is to search by distance)
I'm assuming this restriction is due to OSM's own restrictions and would require probably some "self hosted" spatial search index, but I would appreciate if this was more directly communicated either in the GUI or the DOC (better in the GUI, a very short notice would avoid over 5 days wait time for the client ....)
Perhaps I missed the notice / doc, in that case, could you share where this is informed?
Hi Beda, Christopher is on vacation and let me jump in.
As you may already aware we are just in early phase of openstreetmap and we gradually improve the feature and the related Doc for the same. If we found any issue or missing feature we will be happy to report and escalate to next level.
I switched the maps API to OpenStreetMap:
- hidden link
With the test view you shared I do not have any issue to add the distance filter:
- hidden link
The above test view is added on the following page:
- hidden link
1. I can see the view works now even with OSM
2. I cam also add it to the view once deleting the filter and re-adding
3. Yet, that 100% did not work before, and...
4. Your colleague actually confirmed it is not supposed to work at all with OSM, see https://toolset.com/forums/topic/cannot-add-distance-filter/#post-2832896
So this does not add up to me lol
Are you positive that OSM supports distance search? And if so, how is that actually implemented? OSM has no distance API like google has, afaik, so why I actually found Christopher's statement expected (after the fact).
I just want to avoid telling the client "hey sure we do not need Google Maps", only to then a few days later find we need it anyway 😀
The reason it worked when you tried is that the Google Maps API key was still saved in the settings (even if switching to OSM).
As soon you DELETE that maps api key and THEN switch to OSM it won't work anymore.
So, this is even less expected - it means, we will NEED a Google API key - for distance search supposedly - and yet the MAP setting can be set to OSM and it will use that map, but not that distance search API (since it has none)
I think this needs to be at least escalated as a documentation issue, or to devs to enhance the GUI, since it is clear you need a Google Maps API key even if you switch to OSM - for the distance search. And that API key will be hidden if switching to OSM, which is very confusing at best.
Thanks for the update and yes, address (distance) search works currently using mixure (API key from google to search the address) and you can still use open street map to display the map.
I can confirm if we remove the google map API key from Maps settings the distance search filter is not populated.
I found the following maybe that can help you and maybe you can use it and implement it.
- hidden link
I will raise the concern you shared about updating the Doc and add more clarity and Devs will see if they can implement standalone distance search feature that works with OpneStreetMap without using Google API key.