Skip Navigation

[Resolved] Setting up Map View with Repeatable Fields Group

This support ticket is created 2 years, 8 months ago. 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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 14 replies, has 2 voices.

Last updated by Minesh 2 years, 8 months ago.

Assisted by: Minesh.

Author
Posts
#2313597
Screen Shot 2022-03-10 at 3.07.39 PM.png
image_6483441.JPG

We have the following design (see image attached), for a searchable map.
Each Practioner (user) has a custom post type with multiple addresses and information in a Repeatable Fields Group (inside the group we have the Address Field), and we would create Map View with search filters that allow showing the results as the pdf attached.
Is that possible with Repeatable Fields Group inside a CPT?

#2314115

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

The thing is that searching posts by fields that belong to repeatable field groups is not currently supported.

For instance:
- if you have a "Student" post type and Student post type holds custom fields (Status,Rank) and you created a repeatable field group "Personal Information" with fields (phone number, email address, location etc..).
- You create a view and set this view to query post type "Student" then you cannot include filters for location field (which eventually belongs to repeating field group). When you set your view to query post type "Student", you can only add search fields that is belongs to that post type, in this case (Status,Rank).

First I will require to know what content you want to search and what fields you want to display as result. If you can share admin access details and share all your required information for search and search result fields, once I will review that information and your current setup I will be able to guide you in the right direction.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2316231

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I can see that you have post type "practitioner-address" that holds the repeating field group that is having the address field.

Now, when you say:
- " Search fields" what search fields you would like to add?

I tried to create a test page and test view but when I try to save the page it shows the critical error, now sure why.

Here is the Doc about how you can create custom search using view:
- https://toolset.com/documentation/legacy-features/views-plugin/

Here is the Doc about how you can create Maps:
- https://toolset.com/documentation/legacy-features/maps-plugin/

Would it make more sense to create a "Practitioner" CPT and an "Addresses" CPT and link them via relationships? Would the search and map work with a setup like that?
==>
It could but again, when you set your view with custom search you will have to set your view to query post type either "Practitioner" CPT or "Addresses" CPT.

Having said that for instance "Practitioner" CPT have two custom fields and "Addresses" CPT have five custom fields.
- If you set your view to query "Practitioner" CPT then you can add those two associated custom fields as frontend filters
- If you set your view to query "Addresses" CPT then you can add those five associated custom fields as frontend filters

Its not possible that you set your view to query "Addresses" CPT and add custom fields belongs to "Practitioner" as frontend filters.

I suggest you test this with the test site. Following is a test site I've created, you can login in using the following link:
- hidden link

You can see how the custom search with map is created:
- hidden link

Or you can create your own post types and fields and try to create new page and see how it works.

#2316415

The search fields would be simple text inputs, we'll have a look at the sample site, thank you.

#2317101

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

sure - please play with sample site and let me know how it goes.

#2318515

Hi Minesh,
Thanks for your help.

1. We have the map working now, but we would like to when a result (city or postal code) is not found on the map to show the nearest result instead of on the map. Is that possible?

2. Is it possible to have a link to the pin on the map?? so if I click on "View Location", the page will scroll to the pin on the map.

thanks

#2319307

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

1. We have the map working now, but we would like to when a result (city or postal code) is not found on the map to show the nearest result instead of on the map. Is that possible?
==>
Yes, its possible.

2. Is it possible to have a link to the pin on the map?? so if I click on "View Location", the page will scroll to the pin on the map.
==>
if you mean that when you click on the link it should open related marker on map, then yes, its possible.

But first I would like to know where you created your map? Can you please share URL of that and admin access details.

I have set the next reply to private which means only you and I have access to it.

#2319455

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

To your view that displays the map:
- hidden link

I've added the following code to [no-items-found] section to set the default marker as per the city or zipcode:

[wpv-conditional if="( '[wpv-search-term param='wpv-wpcf-map-city']' ne '' ) AND ( '[wpv-search-term param='wpv-wpcf-map-postal-code']' ne '' )"]
		[wpv-map-marker map_id='map-3' marker_id='marker-3' address="[wpv-search-term param='wpv-wpcf-map-city'],[wpv-search-term param='wpv-wpcf-map-postal-code']"][/wpv-map-marker]
[/wpv-conditional]
[wpv-conditional if="( '[wpv-search-term param='wpv-wpcf-map-city']' ne '' ) AND ( '[wpv-search-term param='wpv-wpcf-map-postal-code']' eq '' )"]
		[wpv-map-marker map_id='map-3' marker_id='marker-3' address="[wpv-search-term param='wpv-wpcf-map-city']"][/wpv-map-marker]
[/wpv-conditional]
[wpv-conditional if="( '[wpv-search-term param='wpv-wpcf-map-city']' eq '' ) AND ( '[wpv-search-term param='wpv-wpcf-map-postal-code']' ne '' )"]
		[wpv-map-marker map_id='map-3' marker_id='marker-3' address="[wpv-search-term param='wpv-wpcf-map-postal-code']"][/wpv-map-marker]
[/wpv-conditional]

For focus on marker, to the content template that you added within view's loop:
- hidden link

I've added the following line of code:

 <a href="javascript:void(0)" class="js-wpv-addon-maps-focus-map js-toolset-maps-open-infowindow-map-map-3-marker-marker-[wpv-post-id]" data-map="map-3" data-marker="marker-[wpv-post-id]">View Location</a>

Now, when you click on the "View Location" link it will open the related marker on map. The above link is added using the "Focus on marker" button that is available with you click on "Fields and Views" button. Please check the following screenshot:
- hidden link

#2319637

Hi Minesh,
#2 is working as expected, thanks.

but for #1 what I meant is if someone search for a City and/or Postal Code and a result is not found, I would like to show the nearest City with the result on the map. does that make sense?

thanks

#2320039
Screen Shot 2022-03-17 at 2.54.36 PM.png
Screen Shot 2022-03-17 at 2.51.28 PM.png

To illustrate the intent for number 1, attached are two screenshots of the same location.

The postal code search brings up no results, but does nicely centre the map on that postal code.

There is actually a location though that must just be in the next postal code over.

Is it possible for the search to return not just the results for exact location, but also the surrounding locations (radius based perhaps)?

Thank you

#2322485

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

No, there is no such feature available as we can control only the input text and based on what we can search or display the results.

#2322975

Hi Minesh,
Is it possible for the postal code part of the search to not actually search, but to just center the map on that postal code?
thanks

#2322979

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

What you mean? I searched using the postcode where no results available:
=> hidden link

I can see map is displayed in center. Do you want something else? if yes, could you please clarify with example.

#2323019

I want to see the nearby results.

In the case of my two screenshots in reply #2320039: the postal code search brings up no results, but there is a location across the street (postal codes are only a few streets in size).

So rather than the postal code "search" searching, can we make it just centre the map?

Thank you

#2323063

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

No, there is no such feature available and there is no workaround I've to offer at the moment.