Skip Navigation

[Gelöst] Display a View of nearby places using address set by Toolset Maps

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

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

Solution:
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:
https://toolset.com/documentation/user-guides/display-on-google-maps/displaying-markers-on-google-maps/
https://toolset.com/documentation/user-guides/passing-arguments-to-views/

This support ticket is created vor 5 Jahre, 9 Monate. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 4 Antworten, has 2 Stimmen.

Last updated by prasadS vor 5 Jahre, 9 Monate.

Assisted by: Nigel.

Author
Artikel
#912182
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?
NO

Is there a similar example that we can see?
NO

What is the link to your site?
in.leisurekart.com

#912216

Nigel
Supporter

Languages: Englisch (English ) Spanisch (Español )

Timezone: Europe/London (GMT+00: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 https://toolset.com/documentation/user-guides/passing-arguments-to-views/ for details about passing values to Views using shortcode attributes.

#912247
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.
Kamshet
Kolad
Lonavala

Please see the attached screenshot for my current Ordering settings.

Kindly help.

#912292

Nigel
Supporter

Languages: Englisch (English ) Spanisch (Español )

Timezone: Europe/London (GMT+00: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.

#913952

No problem. Thank you for the help.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.