Skip Navigation

[Resolved] How to display the marker adress in the map hover box?

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 7 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

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
- 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 3 replies, has 2 voices.

Last updated by Luo Yang 7 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#510517

Hello

I have a simple issue I think but can't find the solution.

I am building a simple Companies directory. Each company can have multiple offices, and each office has its own adress.

I have created a custom post type named Companies.
I have created custom fields, attached to the Companies post type:
- Company name (slug : company-name)
- Office adress (which is a repeater field, adress type, slug : office-address)

I created sample test data.

Company 1
- Office adress 1 : Paris, France
- Office adress 2 : London, UK
- Office adress 3 : New York, US

Company 2
- Office adress 1 : Dallas, US
- Office adress 2 : Berlin, DE
- Office adress 3 : Madrid, ES

I have managed to display the office locations on a map.

My problem :
I would like to display the 'company-name' and the 'office-adress' values from the custom fields when I hover on a marker.
From what I understand, the marker_title attribute manages what is displayed when you hover on a map marker.
If I let the marker_title attribute empty, by default, it displays the post-title.
I have tried including a reference to the custom field :
[types field='office-address'][/types]

but this returns me all the office adresses of the repeater field for one company.

I would like the hover info box to just display the info specific to the marker. How can I do this?
For example, when I hover a marker on the map, I would like to display:
Company 2
Madrid, ES

Here is the simple code
Here is the simple code for displaying info for a single company. I have put question marks where I'm stuck.

[wpv-map-render map_id="map-1"]
[wpv-map-marker 
  map_id="map-1" 
  marker_id="marker-1" 
  marker_title="?????" 
  marker_field="wpcf-office-address"]
[/wpv-map-marker]

Thanks for your help.
Xavier

#510618

Dear xavier,

In your case, one company has multiple address values, you will need to output each address value as a independent map marker, you can use Views shortcode [wpv-for-each] to output multiple map markers of each company, see our document:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-for-each
Iterate through multiple items in a post meta field and output the enclosed text for each item. Including Types repeating fields.

#510798

I'm new to Toolset.

Would you have a code example for this?

#511345

I checked it in my localhost, you are right, if I reference to the custom field : [types field='office-address'][/types], this returns me all the office adresses of the repeater field for one company.
and the [wpv-for-each] shortcode does not work as expected with shortcode [wpv-map-marker], and.
if you agree, we can take it as a feature request.

Currently, I suggest you create a child post type, for example "company-address", with a single instance address field "office-address", in the single "Company", create a view to display the child "company-address" posts and the address field "office-address", then you will be able to use the address field value or child post title as the marker title.

More help:
Creating Post Type Relationships
https://toolset.com/documentation/user-guides/creating-post-type-relationships/

The forum ‘Types Community Support’ is closed to new topics and replies.