Skip Navigation

[Resolved] Different marker icons based on taxonomy

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a Map View with Markers created using an address custom field. I would like to display a different Marker image based on the taxonomy terms applied to the post with the address field.

Solution:
Create three different Marker shortcodes and wrap each in conditional HTML. Test the slug produced by the wpv-post-taxonomy shortcode in the conditional like this:

[wpv-conditional if="( '[wpv-post-taxonomy type="status-woongroep" format="slug"]' eq 'wonend' )"]
   [wpv-map-marker map_id="map-1" marker_id="marker-[wpv-post-id]" marker_title="[wpv-post-title]" marker_field="wpcf-adres-woongroep" marker_icon="https://www.lvgo.nl/cms/wp-content/uploads/2018/08/google-map-home-woon.png" ]Wonend: <strong>[wpv-post-link]</strong>[/wpv-map-marker]  
 [/wpv-conditional]
 
 [wpv-conditional if="( '[wpv-post-taxonomy type="status-woongroep" format="slug"]' eq 'initiatief' )"]
   [wpv-map-marker map_id='map-1' marker_id='marker-[wpv-post-id]' marker_field='wpcf-adres-woongroep' marker_icon="https://www.lvgo.nl/cms/wp-content/uploads/2018/08/google-map-home-initiatief.png"] In oprichting: <strong> [wpv-post-link]</strong>[/wpv-map-marker]
 [/wpv-conditional]
 
 [wpv-conditional if="( '[wpv-post-taxonomy type="status-woongroep" format="slug"]' eq 'bouwend' )"]
   [wpv-map-marker map_id='map-1' marker_id='marker-[wpv-post-id]' marker_field='wpcf-adres-woongroep' marker_icon="https://www.lvgo.nl/cms/wp-content/uploads/2018/08/google-map-home-initiatief.png"] In oprichting: <strong> [wpv-post-link]</strong>[/wpv-map-marker]
 [/wpv-conditional]

Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
https://toolset.com/documentation/user-guides/display-on-google-maps/

This support ticket is created 6 years, 4 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by winyS 6 years, 4 months ago.

Assisted by: Christian Cox.

Author
Posts
#1096317

Hi Christian,

I think the ACF fields conversion problem is solved now.

Can you please respond to my latest questions:

I want to display different markers for different posts, based on the content of the select field lvgo_status_woongroep. Somelthing like this tutorial: https://toolset.com/forums/topic/different-marker-image-in-a-single-map/.

I think it makes more sense to replace the select field by a custom taxonomy "status woongroep" with 3 terms. I already created this custom taxonomy and populated it in 2 custom posts.

But what code do I have to add to my view to display the different markers?
I attach a screenshot of my view (not yet displaying correctly) and the url to view: hidden link (concept, you have to login first)

Thank you.

#1096321

You can place 3 different Marker shortcodes in your content using 3 different Marker icons, and use conditional HTML to show and hide the different Markers based on the taxonomy. I added this code to your View:

         [wpv-conditional if="( '[wpv-post-taxonomy type="status-woongroep" format="slug"]' eq 'wonend' )"]
        	[wpv-map-marker map_id="map-1" marker_id="marker-[wpv-post-id]" marker_title="[wpv-post-title]" marker_field="wpcf-adres-woongroep" marker_icon="<em><u>hidden link</u></em>" ]Wonend: <strong>[wpv-post-link]</strong>[/wpv-map-marker]  
          [/wpv-conditional]
        
          [wpv-conditional if="( '[wpv-post-taxonomy type="status-woongroep" format="slug"]' eq 'initiatief' )"]
          	[wpv-map-marker map_id='map-1' marker_id='marker-[wpv-post-id]' marker_field='wpcf-adres-woongroep' marker_icon="<em><u>hidden link</u></em>"] In oprichting: <strong> [wpv-post-link]</strong>[/wpv-map-marker]
          [/wpv-conditional]
        
          [wpv-conditional if="( '[wpv-post-taxonomy type="status-woongroep" format="slug"]' eq 'bouwend' )"]
          	[wpv-map-marker map_id='map-1' marker_id='marker-[wpv-post-id]' marker_field='wpcf-adres-woongroep' marker_icon="<em><u>hidden link</u></em>"] In oprichting: <strong> [wpv-post-link]</strong>[/wpv-map-marker]
          [/wpv-conditional]
          

The last conditional block should be updated to use the correct marker icon URL and message. We have more information about conditional HTML here: https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

#1097040

Thank you Christian, it works now!