Hello,
I have a post with multiple addresses entered. I am using the post field for address, and I have it set for multiple instances.
I need to loop through the addresses in two places, the first is within a map, using markers. The second is to display all addresses below the map.
I was able to get all of the individual addresses displayed using:
<div class="business-location">
[wpv-for-each field="wpcf-business-location"]
<div class="business-location-item">[types field='business-location'][/types]</div>
[/wpv-for-each]
</div>
However, when I try to do the same thing for the map markers, all of the markers are displaying the same address ... it is the last field entry.
This is the code I am using:
<div class="business-map">
[wpv-map-render map_id='map-2']
[wpv-for-each field="wpcf-business-location"]
[wpv-map-marker map_id='map-2' marker_id='marker-2' marker_title="[types field='business-location' output='raw'][/types]" marker_field='wpcf-business-location' id='$posttype']
<a href="<em><u>hidden link</u></em> field='business-location' format='FIELD_LATITUDE, FIELD_LONGITUDE'][/types]/" target="_blank">
<button type="button" class="btn btn-primary">Get Directions</button>
</a>
[/wpv-map-marker]
[/wpv-for-each]
</div>
I have a feeling it is because I am using the same static marker_id within the wpv-for-each loop, but I can't be sure.
Is there a way to grab a dynamic field id like with for the multiple marker maps?
Like:
[wpv-map-marker map_id='map-search' marker_id='marker-[wpv-post-id]' marker_field='wpcf-business-location'][/wpv-map-marker]
Where the marker_id uses marker-[wpv-post-id]?
The difference, however, is that in one map, I am looping through multiple posts, and in the map I am having trouble with, I am in a single post, and looping only through the multiple address fields.
I hope I have provided enough detail. Please let me know if you have any questions.
Thanks!