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
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.
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
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!
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>
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/