Skip Navigation

[Resolved] Display readapting address field in map

This thread is resolved. Here is a description of the problem and solution.

Problem:
How can I display a Repeating Address Field in a Toolset Google Map?

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.

Relevant Documentation:
https://toolset.com/documentation/user-guides/display-on-google-maps/

This support ticket is created 7 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 5 replies, has 2 voices.

Last updated by tinaH 7 years, 5 months ago.

Assisted by: Beda.

Author
Posts
#532188
multiple instances.png
field setup.png

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.

#532197

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]
#532380

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?

#532413

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.

#532424

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

#533409

Thank you for explaining how repeated map fields work.
I created a multi destination link to create a route on google maps. That worked.