Hi there,
I have these plugins installed on my dev /testing site: Toolset Maps, Toolset Types, Toolset Views, ACF Pro.
I have created a CPT called 'Places' and I want to display these items/places on the map. I am using the Toolset Views plugins to create it.
I have created an address field using both the Toolset custom field (screenshot : toolset.png) + the ACF (screenshot : acf.png).
Below is my test page:
hidden link
I know that we can use the Toolset Custom Field (the Address field) to add the 'markers' to the map (which I am using now and it's working), but I want to know how I can to add the markers to the map using the ACF Google map field (hidden link).
This is the code in my toolset view loop editor:
[wpv-layout-start]
[wpv-items-found]
[wpv-map-render map_id="map-7" map_height="600px" style_json="//sc.thedev.ca/rosetestsite/wp-content/plugins/toolset-maps/resources/json/Silver.json" ]
<p>Please wait while the map is loading...</p>
<!-- wpv-loop-start -->
<wpv-loop>
[wpv-map-marker map_id='map-7' marker_id='marker-[wpv-post-id]' marker_title='[wpv-post-title]' marker_icon='//sc.thedev.ca/rosetestsite/wp-content/plugins/toolset-maps/resources/images/markers/Buildings.png' marker_field='wpcf-place-address']
<h2>[wpv-post-title]</h2>
<p>Toolset field output: [types field='place-address'][/types]</p>
<p>ACF field output: [wpv-post-field name='acf-place-address']</p>
<p>ACF field shortcode output: [acf-place-location]</p>
[wpv-post-body view_template="None"][/wpv-map-marker]
</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-map-render]
(screenshot: toolset-view-map.png )
I've tried to replace it with 'acf-place-address' (the name of the ACF google map field), so it looks like this:
marker_field='acf-place-address'
Changing that doesn't work, and no markers were added to the map.
The 'marker_field' is currently using 'wpcf-place-address' ( which is the toolset custom address field) to display the markers, and I want to see what it outputs. So I have added [types field='place-address'][/types] to the marker popup to show the output value. This outputs the location address.
I've also displayed the ACF google map field output value to the marker popup. This shows a bit more details (such as the longitude and latitude), so I've created a shortcode to only display the location address, which I hope to replace 'wpcf-place-address' from the 'marker_field' attribute.
This is the code that I've used to output the location address (from the ACF field):
add_shortcode('acf-place-location', 'acf_map_location_shortcode');
function acf_map_location_shortcode() {
$output ="";
$location = get_field( 'acf-place-address' );
$output = $location['address'];
return $output;
}
I've tried to use the shortcode in the 'marker_field' attribute (see below):
marker_field='[acf-place-location]'
Unfortunately this still doesn't work. No markers were added to the map.
What info does the toolset map need to display markers onto the map? What am I missing?
Thanks!