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
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
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
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
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
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
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
My issue is resolved now. Thank you!