Tell us what you are trying to do?
I have a custom post type "activities" with:
1) a single field "main location" (address)
2) a repeatable field group "additional locations" containing:
a location (address)
a location type (radio)
3) a hierarchical taxonomy "topics"
I want a view to list multiple posts and a map.
For each post: if a particular term is selected in "topics", and if "additional locations" has at least one value, then I need the map to show markers for all addresses of the "additional locations", for all custom posts filtered in the view. If not, I need one marker for each post, from the address in "main location".
So basically this is about activities that either have one location, or multiple (depending on the activity topic). I want to show multiple activities on a map.
Is there any documentation that you are following?
Not really because there is no documentation on this I guess. The documentation on all blocks related configuration is pretty clear. But I don't think this can be done with blocks. So I need the legacy options and short codes, which is undocumented, apart from the reference guide but it does not provide full examples: https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/
Please provide a step by step example including the code/markup I need for this. Thanks!
Hello,
It is possible with Toolset plugins, you just need to specific the marker's map ID to the same map.
https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#wpv-map-marker
map_id. Mandatory. The unique ID for the map where this marker will be rendered.
If you need more assistance for it, please provide a test site with the same problem, I can setup a demo for you
Thanks Luo! You can access the site here: hidden link
The Activities post type has a "Main locations" field group with both a single field (address) and a repeating field group (address and radio).
The test page for the view and map is Activities 3.
Apart from the approach I suggested, would it somehow make more sense to use another custom post type "Locations" for this, rather than fields on "Activities"? Each "Location" would have one address field. "Locations" and "Activities" would be related post types? Would that simplify things? One thing I can think of is that it would prevent defining the same geolocation multiple times.
I have setup a demo in your website:
1) child post view "Child additional locations view":
hidden link
- Query "Additional Locations" posts
- Filter by:
Select items from the Additional Locations group that are a related to the current post in the loop.
- In view's loop, display the marker shortcode as below:
[wpv-map-marker map_id='map-25' marker_id='marker-[wpv-post-id]' marker_field='wpcf-location'][wpv-post-title item="@additional-locations.parent"][/wpv-map-marker]
2) parent post view "Parent Activities posts view"
hidden link
- Query "Activities" posts
- In view's loop, display the marker shortcode as below:
[wpv-map-marker map_id='map-25' marker_id='marker-[wpv-post-id]' marker_field='wpcf-main-location'][wpv-post-title][/wpv-map-marker]
- In section "Loop editor", outside View's loop, display the map shortcode
[wpv-map-render map_id="map-25"][/wpv-map-render]
As you can see all map and marker shortcodes are the same value: map-25
3) Create a page, display the parent post view:
hidden link
It works fine.
Please let me know if you need assistance to setup the map of single Activity post
And for the new question:
would it somehow make more sense to use another custom post type "Locations" for this, rather than fields on "Activities"?
It depends on yourself, if you want to avoid defining the same geolocation multiple times, you can setup a custom post type "Locations", and setup many-to-many relationship between "Activities" and "Locations"
Thank you. After quite some studying I think I understand the basics of your example. I also managed to create a template for a single Activity post by using a view on the repeatable view group (filter based on the current content selection), plus a map with two markers: both pull data from the same view but one is getting the single address and the other the repeatable address.
Also I tested the same setup but with a related (child) post type Location with each a single address, instead of the repeatable field group in the Activity post type. The basic of that work as well, both for multiple as a single Activity. Indeed this prevents duplicate Location entry as the addresses are not part of the Activity.
Will study on it some more now.
Is this issue resolved? Please let me know if you still need assistance for it, thanks
My issue is resolved now. Thank you!