Skip Navigation

[Resolved] Map Marker Based On Parent Field

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

Last updated by Luo Yang 3 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#2021399
Marker Field.JPG
Ticket Map.JPG

Hey there! Just had a quick question regarding map markers. For reference, 'Tickets' and 'Locations' are both custom post types I have created.

As you can see in the attached image, I have a page on my site that contains a view, and a map of all existing Tickets. The view seems to be populating correctly, while the map does not. The address field we are wanting the map markers to be based on, is a custom field under the Location post type. The view is able to recognize this relationship, while the map does not seem to be able to. While trying to figure this out, we have attempted a few different things, with no luck so far. First, we tried adding a marker through the Map blocks interface. Here, we added a marker, selected ​View Block ​and chose the Tickets view / field which we are using. No markers display. Next, we tried adding the marker through a shortcode placed inside our view loop (following this documentation: https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/ ). We havent been able to figure this method out either. So I guess our question is, can we display map markers based off of the parent Locations Address field? If so, what would that look like? Thanks in advance!

- Dalton

#2021723

Hello,

I assume we are talking about this case:
- One-to-many relationship "locations-tickets" between post types 'Locations' and 'Tickets',
- There is a custom address field in post type 'Locations'

If it is, you can try these:
1) Create a content template, for example "parent-Location-post-information", display the marker shortcode, for example:
[wpv-map-marker map_id="map-1" marker_id="my-marker-[wpv-post-id]" marker_title="[wpv-post-title]" marker_field="wpcf-my-address"]This is the content of the marker popup.[/wpv-map-marker]

Please replace "map-1" with your map ID, replace "my-address" with your custom address field slug.

2) In the view's loop, display above content template shortcode with item attirbute, for example:
[wpv-post-body view_template="parent-Location-post-information" item="@locations-tickets.parent"]

More help:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/
@{relationship-slug}.{relationship-role} is used to retrieve data from a related post.

#2022167
Map Name.JPG
Location Slug.JPG
ViewLoop.JPG
ContentTemplate.JPG

I believe I understood what you were saying? I have created a new content template that contains the map marker shortcode, and called it from my existing page that has my view and map on it. Still no map markers. Am I possibly missing something? Thanks!

- Dalton

#2022371

Looks like I forgot to change the relationship slug the first time around. Needed to be "@locations-to-tickets.parent" instead of "@locations-tickets.parent". Thanks for your help!

#2022389

One more thing:

I am now trying to style the popup text when clicking on each marker. How would I go about adding html tags to this shortcode in the content template so that each popup looks like the following?

<h1>[types field='location-name'][/types]</h1>
<p>[types field='location-address'][/types]</p>

New threads created by Luo Yang and linked to this one are listed below:

https://toolset.com/forums/topic/style-the-popup-text-when-clicking-on-each-marker/

#2022845

I assume the original question is resolved, for other new questions, please check the new thread here:
https://toolset.com/forums/topic/style-the-popup-text-when-clicking-on-each-marker/