Skip Navigation

[Resolved] How to assign different types of markers based on a field value ?

This support ticket is created 3 years, 2 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 8 replies, has 2 voices.

Last updated by FLORENTW330 3 years, 2 months ago.

Assisted by: Minesh.

Author
Posts
#2158857
Screenshot from 2021-09-02 22-59-22.png

I would like to create a page with a View (search + output) and a Map to display 3 differents makers:

- red marker for a custom post "school" with custom field active=True
- green marker for a custom post "school" with custom field active=False
- blue marker for custom post "homeschool"

My problem is that in the setting panel of the Map it's not possible to filter custom fields at marker level, the only option is to assign he marker to a secondary View (search + output).

Could you please tell if my understanding is correct and how I could achieve this ?

Thank you,
Florent

#2159229

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Using Toolset blocks - there is no feature available to display marker conditionally but there is a workaround that we can use the shortcodes or fields and text block and within that we can add the marker's shortcode to display the markers conditionally.

If you can share problem URL and admin access details I'm happy to share you workaround.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) 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.

#2159417

Minesh
Supporter

Languages: English (English )

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

As you can see with the following image: hidden link

I've added three conditions as per your requiremeht.

Now, what you should do it, click on the "Add Field or View" button and search for the marker and try to add the marker as per your requirement.

Please note that your map id is "map-5" and you should change the marker id to "marker-[wpv-post-id]" and set your desired image as per the conditional statement.

As you can see I've already done if for one of the conditional statement.
=> hidden link

[wpv-map-marker map_id='map-5' marker_id='marker-[wpv-post-id]' marker_field='wpcf-adresse-postale'][/wpv-map-marker]

I hope this workaround work with you.

#2159543
Screenshot from 2021-09-03 12-07-20.png
Screenshot from 2021-09-03 12-05-12.png

Hi Minesh,

Thanks, I think I understand the logic behind this workaround. Basically you removed the marker at the map level and created 3 markers (with conditional statements) at View loop level. But I notice that markers are not displayed anymore on the map. Is it because the conditional statement return no posts ? the condition seems correct to me, please see screenshots in attachment.

Also, could you explain how I can customize the marker icon with shortcode ? I can edit the Field and Text element, but what is the appropriate shortcode to customize marker icon ?

#2159587

Minesh
Supporter

Languages: English (English )

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

For more easy readability I've added the shortcode block and added all the condition within this block as given under:


[wpv-conditional if="('[types field="activite" output='raw'][/types]' eq '1') AND ( '[wpv-post-type]' eq 'etablissement' )"]

[wpv-map-marker map_id='map-5' marker_id='marker-[wpv-post-id]' marker_field='wpcf-adresse-postale'][/wpv-map-marker]

 [/wpv-conditional]

[wpv-conditional if="('[types field="activite" output='raw'][/types]' eq '2') AND ( '[wpv-post-type]' eq 'etablissement' )"]


[wpv-map-marker map_id='map-5' marker_id='marker-[wpv-post-id]' marker_icon='//ouischool.net/wp-content/plugins/toolset-maps/resources/images/markers/Buildings.png' marker_field='wpcf-adresse-postale'][/wpv-map-marker]

 [/wpv-conditional]

[wpv-conditional if="( '[wpv-post-type]' eq 'ecole-a-domicile' )"]

[wpv-map-marker map_id='map-5' marker_id='marker-[wpv-post-id]' marker_icon='//ouischool.net/wp-content/plugins/toolset-maps/resources/images/markers/Hospital-2.png' marker_field='wpcf-adresse-postale'][/wpv-map-marker]

 [/wpv-conditional]

You can adjust the marker icon URL as required.

Yes, it will not display the marker icon on the backend but it does display it on frontend.

#2159627

Thanks, much appreciated !

Is there a possibility to customize hover and popup for these markers ?

#2159633

(deleted message)

#2159641

Minesh
Supporter

Languages: English (English )

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

You can add attribute marker_title='my marker title' for marker hover.

And to customize the marker popup content you can add between marker shortcode. For exmaple:

[wpv-map-marker map_id='map-5' marker_title='my marker title' marker_id='marker-[wpv-post-id]' marker_field='wpcf-adresse-postale']

This is my marker POPUP content goes here

[/wpv-map-marker]

#2159769

My issue is resolved now. Thank you!