Skip Navigation

[Resuelto] Display a View of nearby places using address set by Toolset Maps

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

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 hace 6 años, 5 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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)

Este tema contiene 4 respuestas, tiene 2 mensajes.

Última actualización por prasadS hace 6 años, 5 meses.

Asistido por: Nigel.

Autor
Mensajes
#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 - enlace oculto
Kolad - enlace oculto
Kamshet - enlace oculto
Lonavala - enlace oculto

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 (enlace oculto)
I want to display a list of nearby places, that is - Kolad, Kamshet and Lonavala)

If I am viewing the place Kolad (enlace oculto)
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

Idiomas: Inglés (English ) Español (Español )

Zona horaria: 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

Idiomas: Inglés (English ) Español (Español )

Zona horaria: 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.