Skip Navigation

[Resolved] Showing different custom markers on single map

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

Last updated by Shane 5 years, 8 months ago.

Assisted by: Shane.

Author
Posts
#1220308

I wanted to use custom markers for specific (names - or nachname) in my google map.

I looked at the following example:
https://toolset.com/forums/topic/different-marker-image-in-a-single-map/

I registered the "has_term" function.
I inserted the following code in the view loop:

[wpv-layout-start]
[wpv-items-found]<br>
[wpv-map-render map_id="map-1" map_height="450px" map_type="terrain" street_view_control="off"]<br>Bitte einen Moment Geduld, das laden der Karte kann Zeit in Anspruch nehmen![/wpv-map-render]
<!-- wpv-loop-start -->
<wpv-loop wrap="4" pad="true">
[wpv-map-marker map_id="map-1" marker_id="marker-[wpv-post-id]" marker_field="wpcf-geburtsort" marker_icon='[wpv-post-body view_template="marker image"]']<div>[wpv-post-link]<br>[wpv-post-featured-image]<br>[wpv-post-taxonomy type="ereignis"]</div>[/wpv-map-marker]
[wpv-item index=1]
<div class="row ">
<div class="col-sm-3">[wpv-post-body view_template="schleifen-objekt-in-familienkarte"]</div>
[wpv-item index=other]
<div class="col-sm-3">[wpv-post-body view_template="schleifen-objekt-in-familienkarte"]</div>
[wpv-item index=4]
<div class="col-sm-3">[wpv-post-body view_template="schleifen-objekt-in-familienkarte"]</div>
</div>
[wpv-item index=pad]
<div class="col-sm-3"></div>
[wpv-item index=pad-last]
<div class="col-sm-3"></div>
</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]
[wpml-string context="wpv-views"]<br>Leider nichts gefunden![/wpml-string]
[/wpv-no-items-found]
[wpv-layout-end]

And I inserted the following code in the template area of the view:

[wpv-conditional if="(has_term('krueger', 'nachname', null) eq '1')"]hidden link;
[wpv-conditional if="(has_term('mueller', 'nachname', null) eq '1')"]hidden link;

but the new Icons are not showing - although the category "nachname" term is showing correct as "krueger" or "mueller" - i checked.

#1220451

Shane
Supporter

Languages: English (English )

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

Hi Michael,

Thank you for contacting our support forum.

Perhaps you can try it like this.


[wpv-conditional if="(has_term('krueger', 'nachname', null) eq '1')"]

[wpv-map-marker map_id="map-1" marker_id="marker-[wpv-post-id]" marker_field="wpcf-geburtsort" marker_icon='<em><u>hidden link</u></em>;

[/wpv-conditional]


[wpv-conditional if="(has_term('mueller', 'nachname', null) eq '1')"]

[wpv-map-marker map_id="map-1" marker_id="marker-[wpv-post-id]" marker_field="wpcf-geburtsort" marker_icon='<em><u>hidden link</u></em>;

[/wpv-conditional]

I see you are passing the content template itself into the map marker parameter which won't work because the content template doesn't only render the link itself.

Thanks,
Shane

#1220720

Hi Shane,
thanks but nothing changed. Your code goes in the template part of my view right?
Right on top ?

What do you mean by
I see you are passing the content template itself into the map marker parameter which won't work because the content template doesn't only render the link itself.???

I copied the code from the other example - but there were a lot of hidden links, so maybe I am missing something here.

#1220981

Shane
Supporter

Languages: English (English )

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

Hi Michael,

Yes it should go in the template of your view.

I would like to check this exactly for you. Would you mind allowing me to have access to the site so that I can check the template for you ?

The private fields have been enabled for your next response.

Thanks,
Shane

#1222788

Shane
Supporter

Languages: English (English )

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

Hi Michael,

The main issue is with your conditionals.

[wpv-conditional if="(has_term('krueger', 'nachname') eq '1')" ]

I checked for the taxonomy nachname and for the term kreuger and none of those exist on this website.

I'm assuming you want to use this taxonomy here.

hidden link

In this case your conditional would be.

[wpv-conditional if="(has_term('term_slug', 'anzeigename') eq '1')" debug='true']

Where you are going to replace term_slug with the actual slug of the term that you want to check.

Thanks,
Shane

#1222792
download.png

Hi Shane,
what did you change? since your visit my frontend looks like this! (see screenshot).

Also i am using the custom field "nachname" for my terms.
I displayed them temporarily at the bottom of the template view.
[types field='nachname'][/types]

And the terms are displayed correct. So I don't understand why the map is not using it.

#1222797

Sorry,
I saw that you used the debug='true' - so I was able to delete your code.

What I still don't understand is why the term is not used. It is NOT the taxonomy that you pasted, because this one is using full names (first name, surname etc) - and I need only the last name (which is in german "nachname") - and this is a custom field.

#1222799

Ok, so I saw that my syntax maybe wrong - it should be more like this:

[wpv-conditional if="(has_term('krueger', $(wpcf-nachname)) eq '1')" ]

But there is still an error in my new syntax - because it is still not working.

#1222804

With this new syntax
[wpv-conditional if="(has_term('Krüger', $(wpcf-nachname)) eq '1')" debug="true"]
i get this debug info for the right term:

But still the custom markers are not displayed.

####################
wpv-conditional attributes
####################
Array
(
[if] => (has_term('Krüger', $(wpcf-nachname)) = '1')
[debug] => true
)

####################
Debug information
####################
--------------------
Original expression: (has_term('Krüger', $(wpcf-nachname)) = '1')
--------------------
After matching 2 numeric strings into real numbers: (has_term('Krüger', $(wpcf-nachname)) = 1)
Matched '1' to 1
--------------------
Converted expression: (has_term('Krüger', 'Krüger') = 1)
--------------------

#1223064

Shane
Supporter

Languages: English (English )

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

Hi Michael,

You are checking a Custom field and NOT a taxonomy ?

In this case using the has_term() function is definitely not the correct approach. The has_term() function is used when you want to check if a post has the term attached to it.

The correct way should be


[wpv-conditional if="($(wpcf-nachname) eq 'Krüger')"]

[wpv-map-marker map_id="map-1" marker_id="marker-[wpv-post-id]" marker_field="wpcf-geburtsort" marker_icon='<em><u>hidden link</u></em>;

[/wpv-conditional]
 

Take a look at the documentation below to check for custom fields with conditionals.
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-types-fields-and-custom-fields/

Thanks,
Shane

#1223093

My issue is resolved now. Thank you!

#1223168

Sorry Shane, but there is still one thing missing for me. The new custom icons are not showing my Title and Popup.
I cannot click the new map Icons. The default icons work ok.

Any idea on that?

This is the code that I use:
[wpv-map-marker map_id="map-1" marker_id="marker-[wpv-post-id]" marker_title="[wpv-post-link]" marker_field="wpcf-geburtsort" marker_icon='[wpv-post-body view_template="marker image"]']<div>[wpv-post-link]<br>[types field='geburtsort'][/types]<br>[wpv-post-featured-image]</div>[/wpv-map-marker]

Again - this works fine for original map markers, but not with the new uploaded - custom markers.

p.s. sorry, but I already removed your access for my website.

#1223170

Shane
Supporter

Languages: English (English )

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

Hi Michael,

I think the issue is that you didn't add back the information to your marker like this


[wpv-conditional if="($(wpcf-nachname) eq 'Krüger')"]
 
[wpv-map-marker map_id="map-1" marker_id="marker-[wpv-post-id]" marker_field="wpcf-geburtsort" marker_icon='<em><u>hidden link</u></em>;

<div>[wpv-post-link]<br>[types field='geburtsort'][/types]<br>[wpv-post-featured-image]</div>

[/wpv-map-marker]


[/wpv-conditional]

Also I noticed that you have the marker code outside of the template area for your view. I would recommend adding this to the template area of your view where the conditional is.

Please let me know if this helps.

Thanks,
Shane