Skip Navigation

[Résolu] Display a View of nearby places using address set by Toolset Maps

Ce fil est résolu. Voici une description du problème et la solution proposée.

A Places post type has an address field. When viewing one place, how to show a map with other nearby places?

You use a View to create the map as normal, but when inserting the View in a template for Places you include a distance Query Filter to show places within a certain distance of the location which is passed by shortcode attribute 'mapcenter'.

Then when you insert the View in the template you use the types address field to provide the mapcenter attribute, like so:

[wpv-view name="nearby-locations" mapcenter="[types field='home-address'][/types]"]

Relevant Documentation:

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.

This topic contains 4 réponses, has 2 voix.

Last updated by prasadS Il y a 3 années et 1 mois.

Assigned support staff: Nigel.

Screen Shot 2018-06-12 at 12.15.30 PM.png

Tell us what you are trying to do?

I have a custom post type named 'Places' which includes an address field.
Real example:
Mumbai - hidden link
Kolad - hidden link
Kamshet - hidden link
Lonavala - hidden link

I have created a view named 'Nearby Places (Maps)'. Using this view, I want to display a list of nearby places (within 300 km).

I want to display this view on the Place page.

If I am viewing the place Mumbai (hidden link)
I want to display a list of nearby places, that is - Kolad, Kamshet and Lonavala)

If I am viewing the place Kolad (hidden link)
I want to display a list of nearby places, that is - Mumbai, Kamshet and Lonavala)

and so on.

Please help me with the options I should select in the Query Filter to achieve this. (Screenshot attached)

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?



Languages: Anglais (English ) Espagnol (Español )

Timezone: Europe/London (GMT+01:00)

Hi there

It looks like you are most of the way there.

The Query Filter needs to have the location to be used as the map centre passed to it as a shortcode attribute.

In your screenshot you already selected that option, for an attribute called "mapcenter".

So you would edit the template you use for single places and insert the View, and when you insert the View set a mapcenter attribute using the value of your address field.

Something like

[wpv-view name="nearby-locations" mapcenter="[types field='home-address'][/types]"]

where your View name and address field slug may be different.

See for details about passing values to Views using shortcode attributes.

Screen Shot 2018-06-12 at 2.25.11 PM.png

Wow! This worked perfect. Thanks a ton.

Just one more help needed. How do I set the Ordering to display the closest locations first (ascending).

For example,
If I am viewing the place Mumbai, the view should display the Nearby Places in the following sequence. (As I know the distance).

Lonavala (82.8 km)
Kamshet (105.4 km)
Kolad (126.6 km)

At the moment, it is showing in the following sequence.

Please see the attached screenshot for my current Ordering settings.

Kindly help.



Languages: Anglais (English ) Espagnol (Español )

Timezone: Europe/London (GMT+01:00)

Unfortunately ordering by distance is currently not supported.

We have a feature request for this—it is a fairly obvious use case—and it will be implemented, but I can't say when for now.

I'm sorry, but there is no workaround I can offer to implement it in the meantime.


No problem. Thank you for the help.