I am trying to create a map view with multiple locations on a single post (event-plan).
The values are from a field that allows multiple instances.
Can't get it to work.
In post body:
[wpv-map-render map_id='jamtli-planritning' map_width='100%' map_height='335px' marker_icon='<em><u>hidden link</u></em>
[wpv-map-marker map_id='jamtli-planritning' marker_id='jamtli-planritning-marker-11' marker_title='[wpv-post-title]' marker_field='wpcf-eventplan-locations']
<strong>Zon</strong><br>
Vägbeskrivning<br>GoogleMaps: Klicka <a href="<em><u>hidden link</u></em> field='eventplan-locations' format='FIELD_LATITUDE,FIELD_LONGITUDE' separator=', '][/types]" target="_blank">HÄR</a>
[/wpv-map-marker]
See images for the field.
Based on another topic I tried this, didn't work.
[wpv-map-render map_id='jamtli-planritning']
[wpv-for-each field="wpcf-eventplan-locations"]
[wpv-map-marker map_id='jamtli-planritning' marker_id='marker[wpv-post-id]' marker_field='wpcf-eventplan-locations']
<a role="button" class="btn btn-primary" href="<em><u>hidden link</u></em> field='eventplan-locations' format='FIELD_LATITUDE,FIELD_LONGITUDE'][/types]/" target="_blank">Get Directions
</a>
[/wpv-map-marker]
[/wpv-for-each]
I understand you have an Address Field, it's repeatable, and you want to show the Addresses saved for one post, on that very post.
Is this correct?
If so, please follow these steps, they should be the path to the solution:
1. Install Types and Views at least
2. Create a Custom Field of Type "Address" and make it repeatable
3. Get a Google Maps API and save it in Toolset > Settings > Maps
4. Create a Post, and save several Addresses for it
5. In the Post Body, or it's Content Template, you use the "Fields and Views" GUI to insert the Map and the Fields.
This will produce something alike this:
[wpv-map-render map_id="map-1"]
[wpv-map-marker map_id="map-1" marker_id="marker-1" marker_field="wpcf-address"]
[/wpv-map-marker]
That will produce a Map with all address field instances projected on it as markers.
I tested that on a local install with Toolset at it's latest version, and no other Software.
Did you follow the same steps?
Sorry for not being more clear.
Yes, your code gives me multiple markers on a map.
But, I am also trying to add a "get directions" link to each marker in a popup.
[php]
hidden link field='eventplan-locations' format='FIELD_LATITUDE,FIELD_LONGITUDE'][/types]/" target="_blank">Get Directions
[php]
The problem is that I get the coordinates for all instances on every marker. So the "get directions" button doesn't work.
I think you want to display each instance of the repeating Field of The Address, each in that marker popup.
Repeating Fields can be single-displayed using a separator, which can be HTML.
But that will still display them all together, just separated by some (can be quite extensive) HTML.
What you can try to use is the wpv-for-each ShortCode.
In the GUI this is to find as the "Post Field Iterator".
There you can add what post Field you want to iterate (your Address Field of course) and set a start and end index (in your case, always just 1-1, 2-2, and so on)
Then, you can display single items of the repeating Field.
But it requires you to add that for each Item of repeating Field.
And that needs to be done manually.
It also does not allow to have a different item in each marker, as the markers are displayed with one ShortCode (one instance only)
As such, unfortunately, this is not possible with the Repeating Field
Thank you for explaining how repeated map fields work.
I created a multi destination link to create a route on google maps. That worked.