Skip Navigation

[Resolved] How to vary the marker icon based on field content

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

Problem:

The issue here is that the user wanted to switch between the 2 different markers based on an option selected in a Post.

Solution:

What you need to do is to use our views conditional shortcode.

https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-types-fields-and-custom-fields/

Use this to check the custom field value to see what is set then use it to load the different marker.

This support ticket is created 6 years, 6 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 4 replies, has 2 voices.

Last updated by coc-admin 6 years, 6 months ago.

Assisted by: Shane.

Author
Posts
#922557

Tell us what you are trying to do? I have a map with a marker at the address of each trash or recycle container in the city. I'd like to use one icon for "trash" and another for "recycle". Those values are in a field in the Container post. Is this possible?

Is there any documentation that you are following? https://toolset.com/documentation/user-guides/display-on-google-maps/displaying-markers-on-google-maps/

Is there a similar example that we can see?

What is the link to your site?

#922709

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Kenn,

Thank you for contacting our support forum.

Are you listing this out on a view or is this for a content template ? Either way the method is the same.

What you need to do is to use our views conditional shortcode.

https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-types-fields-and-custom-fields/

Use this to check the custom field value to see what is set then use it to load the different marker.

Please try this and let me know if this helps.
Thanks,
Shane

#922935

Thanks for the information!

#948490

I reopened the ticket just to add this comment in case it helps others:

I found an even easier way to vary the markers. I can use marker_icon="hidden link field='my-custom-field'][/types].png". This came from documentation page https://toolset.com/2018/02/toolset-maps-features-in-reference-sites-viewing-geolocation-and-filtering-by-distance-in-action/. It works beautifully!

#950256

Unfortunately, I had to back off from this and return to conditional statements. It ALMOST worked. But the [types] shortcode embedded in the url did not expand completely. It brought in the correct image, but it left other errors in its wake. 🙁 It was worth a try!