Skip Navigation

[Resolved] Displaying address from related post in a map

This support ticket is created 4 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.

Our next available supporter will start replying to tickets in about 1.14 hours from now. Thank you for your understanding.

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/Karachi (GMT+05:00)

This topic contains 9 replies, has 4 voices.

Last updated by wD 4 years, 1 month ago.

Assisted by: Waqar.

Author
Posts
#1793501

wD
Screen Shot 2020-09-28 at 5.02.29 PM.png

Tell us what you are trying to do?
I have two custom post types, Listings and Parks. One park can have many listings. Each listing can have an address, or it can be related to a park, which has a park address. I have a map with a view marker that is set to the view block of Recent Listings, and the field selected is the Park address (from related parent Parks). However, nothing shows up on the map and it is centered somewhere in the ocean. If I select to show the listing address, the map works fine.

Is there any documentation that you are following? No.

Is there a similar example that we can see? No.

What is the link to your site?
hidden link

#1794237

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

When you add a Map that gets its markers from a View block on the same page, the source for the markers is the post type chosen in the Content Selection for the View.

In the settings for the markers (visible in your screenshot) there isn't an option to refer to something else, e.g. the parent of the posts in the View, so I'm not quite sure what exactly you are trying to do.

If you want to display a list of listings but markers of parks, you can use 2 Views, one to output the listings, and another one to act as a source for the map where the content selection is park posts themselves. You don't have to add anything to the output of the View, it can output nothing, just serve as the source for the map.

#1794545

wD

What I want to do is have the markers on the map show the Park addresses. In field selector for the block, there are two options: Listing Address (a custom field in Listings) and Park Address (a custom field in the parent Park). Which makes me think it should be able to show the Park Address, since it allows me to select it. Is my assumption incorrect?

#1795183

Hello,

It should be possible with a nested view, for example:
1) Parent post view:
- Query Listings posts
- In view's loop, display below child post view

2) Child post view
- Query Parks posts
- Filter by post type relationship between "Listings" and "Parks"
- In view's loop, display the marker shortcode:
https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#wpv-map-marker

3) Create a page, display:
- Map shortcode
https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#wpv-map-render
- Parent post view's shortcode

You just need to display all marker into the same map of step 3)

#1796273

wD

Is there some documentation on how to add a nested view? When I tried to add one it said "Nested views creation is not supported at the moment." Maybe I'm doing it the wrong way? Or does this not work with Toolset Blocks yet? I have tried creating a view within a view, and also creating a view outside and then moving it inside the view block. Both ways I get the message that it is not supported.

#1797675

Hi,

Thanks for writing back.

Your observation is correct and currently, it is not possible to nest views, when using the new Blocks editor.

I was able to make this work on my test website, using the following steps

1. I removed the marker information from the "Map" block.
( screenshot: hidden link )

2. Next, I added a "Fields and Text" block inside the view's loop and inserted the marker's shortcode, manually like this:
( ref: https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/ )


[wpv-map-marker map_id='map-1' marker_id='marker-[wpv-post-id]' marker_field='wpcf-park-location' item='@park-listing.parent'][/wpv-map-marker]

Please make sure to:

- replace "map-1" with the map ID set in the map block.
- replace "park-location" with the actual slug of the "Park address" field.
- replace "park-listing" with the actual slug of the Park Listing relationship.

This will make the map marker get the address information from the current listing's attached park post.

regards,
Waqar

#1799589

wD

Hello Waqar

This sounds promising, but I was not able to make it work. Here is the shortcode I used:

[wpv-map-marker map_id='map-5' marker_id='marker-[wpv-post-id]' marker_field='wpcf-park-address' item='@park-listing.parent'][/wpv-map-marker]

The map ID is right, and so are the slugs for park address and the park listing relationship. But still nothing shows up on the map. What am I missing???

Erin

#1799777

Hi Erin,

Can you please share temporary admin login details along with the link to a page with this map?

Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.

regards,
Waqar

#1802989

Thank you for sharing the admin access.

During troubleshooting, I noticed that a ";" character existed in the map marker shortcode after the "map_id" attribute:


[wpv-map-marker map_id='map-5'; marker_id='marker-[wpv-post-id]' marker_field='wpcf-park-address' item='@park-listing.parent'][/wpv-map-marker]

I've removed it and the map markers are showing now.

regards,
Waqar

#1803451

wD

My issue is resolved now. Thank you!