Hey,
I hope this question has not been answered before, thanks in advance.
I want to make an archive where the elements within archive loop contains a map with a marker, based on a dynamic address or coordinates. So very ordinary, but with a map instead of a featured image.
However, I'm getting the following message when adding the map block:
Map block cannot be inside the View block. If you want map markers to come from a View, place the Map block outside the View and in the Marker section, select View block for the Source for the marker option.
This is not possible, or is there something I have missed? Maybe a more detailed description of how I actually do it
Hello and thank you for contacting the Toolset support.
Indeed, you can't add a map block inside a view. The view needs to be outside of the view, which means that you can't have a map per post in the view.
However, we can work around this limitation using a content template or using shortcodes. I run a small test on this test site and I was able to implement both techniques:
- Using a content template: Create a content template and assign it to the post type. This will let you choose the marker dynamic source. Check this screenshot hidden link Then you can unassign the content template from the custom post type. Use this content template inside the view.
- Use Maps shortcodes, inside a Fields&Text block, instead of a map block.
Use the following link to login to my test site hidden link
For the first technique:
- Content template: hidden link
- Page with the view: hidden link
- Result: hidden link
For the second technique(easiest technique):
- Page with the view: hidden link
- Result: hidden link
The used shortcodes are:
[wpv-map-render map_id="map-[wpv-post-id]"][/wpv-map-render]
[wpv-map-marker map_id='map-[wpv-post-id]' marker_id='marker-[wpv-post-id]' marker_field='wpcf-location'][/wpv-map-marker]
You can insert the Maps shortcodes using Toolset interface. Check these screenshots hidden link hidden link
Read more about the Maps shortcodes https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/
Note that I have used the wpv-post-id shortcode in the map and the marker IDs to make them dynamically unique.
I hope this helps. Let me know if you have any questions.