Skip Navigation

[Resolved] different marker image in a single map

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

Problem:
Display the map marker as different icon depends on the taxonomy term.

Solution:

Relevant Documentation:
1) Create a content template "marker image" to output the marker icon depends on the term, for example:

[wpv-conditional if="(has_term('cat1', 'category', null) eq '1')"]http://primapower.easytechmedolago.it/wp-content/uploads/2016/02/heady_link1.gif[/wpv-conditional]
[wpv-conditional if="(has_term('cat2', 'category', null) eq '1')"]http://primapower.easytechmedolago.it/wp-content/uploads/2016/02/heady_link2.gif[/wpv-conditional]

2) setup the map marker shortcodes like this:

[wpv-map-marker map_id='map-1' marker_id='marker-[wpv-post-id]' marker_field='wpcf-address' marker_icon='[wpv-post-body view_template="marker image"]'][wpv-post-link][/wpv-map-marker]

100% of people find this useful.

This support ticket is created 8 years, 1 month 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 12 replies, has 3 voices.

Last updated by Jonathan Toledo 8 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#370294
Schermata 2016-02-24 alle 16.04.41.png

I am trying to: I need to display 3 different ctagories of address post type in a map, each category needs a specific marker, and this categories have to be filterable

I visited this URL:

I expected to see:

Instead, I got:

#370507

Dear aldo,

Yes, you can specific different icon for different markers, you can add attribute "marker_icon" in the shortocde [wpv-map-marker],
For example there are two posts in the custom types, each post has one term in category:
post1 (cat1)
post2 (cat2)

Then you can create two different icon in your website:
hidden link
hidden link

Then in shortcode [wpv-map-marker] you can specific the marker_icon as below:
[wpv-map-marker map_id='map-2' marker_id='marker-2' marker_icon="hidden link type='category' format='slug'].png" address='....][/wpv-map-marker]

More help:
https://toolset.com/documentation/views-shortcodes/#wpv-post-taxonomy
description:
Output the taxonomy for the current post.

#372220

I've not understand this shortcode...

[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
[wpv-map-render map_id="map-2" map_width="100%" map_height="450px" single_zoom="2" scrollwheel="off" double_click_zoom="off"]
<wpv-loop>
[wpv-map-marker map_id='map-2' marker_id='headquarters' marker_icon='hidden link' marker_field='wpcf-address'][wpv-post-body view_template='None'][/wpv-map-marker]
</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]
[wpml-string context="wpv-views"]No items found[/wpml-string]
[/wpv-no-items-found]
[wpv-layout-end]

Can you explain more, this is my loop output and with this i see in the map all the markers with the same icon, but I need to have the differrent icons by category

In custom type I have 3 categories: headquarters, Companies, Agents
so i need to display in a single map this post with 3 different icons, plus I need to filter by a dropdown menu like screenshot

thanks
Aldo

#372417

See below live website:
hidden link
user/pass: xgren/111111

posts which has term "cat1" display marker icon "heady_link1.gif" in the map
posts which has term "cat2" display marker icon "heady_link2.gif" in the map

Here are the detail steps:
1) Dashboard-> Views-> Settings-> Compatibility
in option "Functions inside conditional evaluations" add wordpress function has_term

2) Create view, in the view's loop use map marker shortcode like this:
hidden link

[wpv-map-marker map_id='map-1' marker_id='marker-[wpv-post-id]' marker_field='wpcf-address' marker_icon='[wpv-post-body view_template="marker image"]'][wpv-post-link][/wpv-map-marker]

3) in the content template use [wpv-conditional] shortcode to the term of current post, and output correspond marker icon:

[wpv-conditional if="(has_term('cat1', 'category', null) eq '1')"]<em><u>hidden link</u></em>
[wpv-conditional if="(has_term('cat2', 'category', null) eq '1')"]<em><u>hidden link</u></em>

hidden link

Hope it help

#372498
Schermata 2016-03-03 alle 10.17.52.png
Schermata 2016-03-03 alle 10.18.00.png
Schermata 2016-03-03 alle 10.18.15.png
Schermata 2016-03-03 alle 10.18.25.png

I've followed your guide but still the markers are the same for the different categories
see my screenshot with my settings

I don't understand where is the mistake.
thanks again
Aldo

#372768

It seems you are using different views,
1) Screenshot:
hidden link
This is a view which should output the result as the test site:
hidden link
see the post list under the google map

2) but screenshot:
hidden link
It is outputting result from another view.

Please check it, if you need more assistance for it, please duplicate same problem in a test site, and fill below private detail box with login details. thanks

#372833

Thanks for the details, in your case is using custom taxonomy "dealer-category", so the codes of content template should be:

[wpv-conditional if="(has_term('headquarters', 'category', null) eq '1')"]<em><u>hidden link</u></em>
[wpv-conditional if="(has_term('group-companies', 'category', null) eq '1')"]<em><u>hidden link</u></em>

Please test again, check if it is what you need

#372853

Thanks for your help but still someting is wrong, please check with the admin / pwd
Aldo

#373239

Sorry, in your case is using custom taxonomy "dealer-category", you will need to replace "category" with "dealer-category",
so the codes of content template should be:

[wpv-conditional if="(has_term('headquarters', 'dealer-category', null) eq '1')"]<em><u>hidden link</u></em>
[wpv-conditional if="(has_term('group-companies', 'dealer-category', null) eq '1')"]<em><u>hidden link</u></em>
#373331
Schermata-2016-02-24-alle-16.04.41.jpg

Great!!! now is working...
Now I need to add a filter by a dropdown menu for area custom taxonomy and a button to select the dealer taxonomy like this screenshot:

For the dropdown I'm fine with this code:
<div class="rel_pro">
[wpml-string context="wpv-views"]
<p>Select area: </p>
[/wpml-string] [wpv-control taxonomy="area" url_param="wpvarea" type="select" default_label="All"]</div>

I need to set the "button section" with the icons.
thanks
Aldo

#373371

You can setup the parameter filter form by following our document:
Parametric search – Letting Visitors Filter Content
https://toolset.com/documentation/user-guides/front-page-filters/

And since your original question has been resolved, I suggest you create new thread for new question, it will help other users to find the answers.

#373372

Ok thanks

#404824

Thank you for solution Luo Yang!
I have a doubt. I wanted to differentiate by Posts Fields instead of category. It's possible?
I have a Post Field that works by radio button.

Field slug: tipo-de-unidade
Options:
- type1
- type2

Something like this :

[wpv-conditional if="(has_term('type1', 'tipo-de-unidade', null) eq '1')"]<em><u>hidden link</u></em>
[wpv-conditional if="(has_term('type2', 'tipo-de-unidade', null) eq '1')"]<em><u>hidden link</u></em>

Thanks!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.