Skip Navigation

[Resolved] Use the ACF google map field to add markers to the Toolset Map

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 8 months, 3 weeks ago.

Author
Posts
#2697492
toolset-view-map.png
toolset.png
acf.png

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!

#2697566

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

The address field is a special field that at face value appears to just store the text address of a location returned by the Google API, but is also connected to a special cache table that links this to the location coordinates.

The map markers are set up to work with this Toolset address field, and won't work with other non-Toolset fields, even if they have similar content.

So using an ACF location field won't work, I'm afraid.

#2697619

Alright! Thanks for your help on this!