Problem: I have a View of posts that shows Markers on a Google Map. I would like to display a different Marker icon for each post depending on a taxonomy term. Each post will only have one term from this custom taxonomy.
Solution: You can use nested Views to show different icons based on the term.
- Create a new taxonomy View of categories (whatever taxonomy holds the terms museum, scenic road, etc).
- Add a Query Filter, filtered by taxonomy term, set by the current post in the loop. This means that the View will loop over all the terms associated with each POI post.
- In the Loop Output, insert a marker using the icon file based on the current term slug. So if you set up your icon file names to use a standard naming convention like "icon-poi-marker-termslug.png" you can just replace "termslug" each time with the corresponding term slug:
[wpv-layout-start] [wpv-items-found] <!-- wpv-loop-start --> <wpv-loop> [wpv-map-marker map_id="map-6" marker_id="marker-[wpv-taxonomy-id]" marker_icon="/wp-content/path/to/icon-poi-marker-[wpv-taxonomy-slug].png" marker_field="wpcf-address"][/wpv-map-marker] </wpv-loop> <!-- wpv-loop-end --> [/wpv-items-found] [wpv-no-items-found][/wpv-no-items-found] [wpv-layout-end]
- Modify the map ID, the marker_icon image filepath, and the marker_field slug as needed.
- Insert this new View inside the wpv-loop tags of your View of POIs.
Relevant Documentation:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-taxonomy-slug
https://toolset.com/documentation/user-guides/display-on-google-maps/#displaying-markers
https://toolset.com/documentation/user-guides/using-a-child-view-in-a-taxonomy-view-layout/
Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.
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 6 years, 11 months ago.
Assisted by: Christian Cox.
The forum ‘Types Community Support’ is closed to new topics and replies.