Skip Navigation

[Resolved] Displaying map marker information for repeating field

This support ticket is created 4 years, 1 month 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.

Our next available supporter will start replying to tickets in about 1.75 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 8 replies, has 2 voices.

Last updated by AlimB3245 4 years ago.

Assisted by: Waqar.

Author
Posts
#1821881

Hi

I have this page where I have a map that displays Branch Office Addresses
hidden link

On the Pop Up Preview I have used this code
[types field='branch-office'][/types]

And when I click on the marker i'd expect to see just the address of that branch but it displays all the addresses as branch office is a repeatable field

Please advise how to resolve this

#1825771

Hi,

Thank you for waiting.

During testing on my website, I noticed that there is no built-in option available inside the "Map" block, which can be used to extract a specific instance of the repeating location type field.

I've shared these findings with the concerned team for further review and for now, you can use the following workaround, to achieve this:

1. Please, unselect the location field from the marker settings in the "Map" block.
( example screenshot: hidden link )

2. Next, include a "Fields and Text" block below the map block and in the HTML mode, include the "wpv-map-marker" shortcode, wrapped inside the "wpv-for-each" shortcode:

( ref: https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#wpv-map-marker & https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-for-each )


[wpv-for-each field="wpcf-post-location"]
[wpv-map-marker map_id='map-1' marker_id='marker-1' address='[types field="post-location"][/types]']
[types field="post-location"][/types]
[/wpv-map-marker]
[/wpv-for-each]

Note: Please replace "post-location" with the actual slug of the field and "map-1" with the actual map ID set in the map block.

regards,
Waqar

#1827219

Hi Waqar

Thanks for the update..:-).. I hope this feature gets added to the maps module soon so that we don't need to use the workaround..:-)..

It worked fine on hidden link and here's the result

hidden link

I've improvised a bit with adding a View On Google Maps link..;-)..

However I tries the same thing on another subsite - hidden link
and I was getting weird results.. there are 2 branch address here and it's getting combined to 1.. Earlier the problem was that the addresses were getting combined but now the markers are getting combined or rather it's just one marker for 2 address..

hidden link

Here's the content template for this..
hidden link

Please advise what am I doing wrong..

Regards,
Alim

#1831959

Hi Waqar,

Any update on this?

Regards,
Alim

#1832781

Hi Alim,

Thank you for waiting.

I've been running some tests and the limitation of my suggested workaround is that it would work for prominent locations, like the city, state, country names, or landmarks, but in case of less accurate or closely located addresses, it can bring in unexpected marker results.

To make this more precise, instead of the "address" attribute, the "lat" and "lon" will need to be used for the "wpv-map-marker" shortcode.
( ref: https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#wpv-map-marker )

I'm currently testing this approach and will be able to share an update, by the end of the day today.

Thank you for your patience.

regards,
Waqar

#1834539

Hi Alim,

Thank you for waiting.

During testing on my website, I noticed that my originally suggested solution of using the "address" attribute worked correctly, even when I used the same location field data as the post "Dr Monga Opticians".

I checked the code added to your website's content template and found that the closing "[/wpv-for-each]" is missing. Adding this in the "Fields and Text" block fixes the missing marker issue.

To make this even more precise and use lat and lon attributes, you can optionally update the whole code to:


[wpv-for-each field="wpcf-branch-office"]
[wpv-map-marker map_id='map-6' marker_id='marker-6' lat='[types field="branch-office" format="FIELD_LATITUDE"][/types]' lon='[types field="branch-office" format="FIELD_LONGITUDE"][/types]']
<b>[wpv-post-title]</b><br>
[types field="branch-office"][/types]<br>
<a href="<em><u>hidden link</u></em> field='branch-office' output='raw'][/types]" target="_blank" rel="noopener noreferrer">View on Google Maps</a>
[/wpv-map-marker]
[/wpv-for-each]

regards,
Waqar

#1834949

Hi Waqar

My apologies for missing out on the closing of the [wpv-for-each] tag.. I've fixed it and it works fine..:-)..

I had one quick query.. the MAPS API works only in Unrestricted Mode on Google Developers Console.. is this correct? Is there anyway I can have the API restricted to use only from my domains? If it's a feature request then can you please consider this as a feature request? Or please do guide me on how do I ask for this as a feature request.

Regards,
Alim

New threads created by Waqar and linked to this one are listed below:

https://toolset.com/forums/topic/split-using-domain-restricted-google-maps-api-key/

#1835305

Hi Alim,

Thanks for the update and glad that it is working now.

I've created a seperate ticket for your new question and will reply to it shortly.
( ref: https://toolset.com/forums/topic/split-using-domain-restricted-google-maps-api-key/ )

You're welcome to mark this ticket as resolved and start a new one for a different question or concern.

regards,
Waqar

#1835451

My issue is resolved now. Thank you!