Home › Toolset Professional Support › [Resolved] Adding DIRECTIONS or VIEW ON GOOGLE MAPS link to maps
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 10 replies, has 2 voices.
Last updated by Christopher Amirian 2 years, 7 months ago.
Assisted by: Christopher Amirian.
Tell us what you are trying to do?
We have two pages with maps (one is a Toolset Template page) that need a link with either a VIEW ON GOOGLE MAPS or a DIRECTIONS link. I see all the other locations on the map have this feature built-in, but I need to code it for our links as well.
Is there any documentation that you are following?
I tried to go off of this, but I couldn't get code to work (looks like the concept being fully integrated is still in development, so we're using workarounds?): https://toolset.com/forums/topic/is-there-a-means-of-getting-directions-using-toolset-maps/
Is there a similar example that we can see?
I've uploaded an image of what this looks like on one of our maps, where a standard location shows the link.
What is the link to your site?
Here are the two pages where we want to add the links:
hidden link
hidden link
The Toolset credentials I created for you are active, so please feel free to login to the site.
Thank you!
Hi there,
That is correct, unfortunately, this is not possible to do unless some form of custom code is being used. The Google API we use does not allow for direction mapping.
You are welcome to get the help of a developer to integrate such a feature for you:
https://toolset.com/contractors/
Thanks.
Hey Guys,
I've got a few things to note on the situation with the maps and directions...
First, when I researched this a couple of days ago, this issue was first brought to Toolset's attention a whopping 6.5 years ago, so I was completely shocked to see that it still hasn't been integrated into the maps. This is an extremely important thing for ANY site that's showing locations to visitors, so I would consider it a DEFCON 1 issue, definitely not something that should be sitting on the backburner for 6.5 years.
Second, with us being in this period when the integration doesn't yet exist, a documented workaround really needs to be out there in an FAQ at this point. We can create links to maps at will from anywhere these days, but it requires knowing what code snippet to pass from the dynamic data we get out of Toolset loops. If this can be done as part of our ticket here, that would be outstanding, and I'm sure make a lot of people happy. We really need a workaround documented for us here vs. being told to instead use a Toolset contractor.
Last thing, the site I'm working on now is a newer version of older site that used Google Maps. That site used the plugin WP GO MAPS, which you can see here: hidden link. We had no problem popping a seamless DIRECTIONS link into maps with that plugin (as of maybe 5-6 year ago?), so if it's an API issue as I keep seeing mentioned, perhaps looking into what they're doing can light the way for Toolset. Just a thought to maybe help out.
Hopefully that helps for the long-term future, but for the short term future, if you could please work with us on a documented workaround, that would be great.
Thanks.
Hi there,
I appreciate your answer and I will surely inform the dev team about the point that you mentioned regarding the API integration and will link to the plugin that you mentioned so it might be a good testing case.
Having said that it does not change the fact that it is not implemented and you might indeed be in need of a developer to implement the functionality.
I did research the Google direction links and came up with this explanation:
https://stackoverflow.com/questions/16326143/google-maps-directions-api-equivalent-url
According to the link above a URL like the one below can be useful:
<em><u>hidden link</u></em>
So in the parameters of the URL, you can add the starting address and destination address.
So for example, if you have two address custom fields for start and destination you can replace the addresses like this:
<em><u>hidden link</u></em> field='starting-address'][/types]&daddr=[types field='destination-address'][/types]
Here is the documentation on how to retrieve custom fields using the shortcode (Check the examples):
https://toolset.com/documentation/customizing-sites-using-php/functions/#address
If you need to know how to retrieve data inside a loop that might be useful you can read the documentation below:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/
Please kindly consider this as an FAQ that can be used, we are unable to give you the exact code as this is what a developer should do as a customization.
Thanks.
Hi Christopher,
My apologies on this, I was inadvertently OVERSTATING what we need here. It's not that we need the directions to pull up (although that is certainly a nice to have), but rather just an accurate VIEW ON GOOGLE MAPS link. That way they can get the directions there on Google if needed. We're referring to it as DIRECTIONS on our site, but it's really just VIEW ON GOOGLE MAPS to be more precise.
I think WP GO MAPS may have sent the current location - destination location over in their API, giving a true Directions link (not 100% sure there), but if we just get the user to the Google page so they're one click away from directions, that's actually perfect (since they may not even want directions, but rather just to see the location isolated on the map).
Really sorry about that, I didn't mean to muddy the waters. So if you do have clean code already set up for this (and maybe I have been searching in previous tickets incorrectly since I kept calling it DIRECTIONS!), that would be great. We just need to cleanly code the pass over to Google with the correct address link from the Toolset view.
Please let me know, and thanks again for your help.
-- Eric
Hi there,
The principle is exactly the same for the view location. You need to get the data from Toolset.
I am not sure how you add your data, but if you added the address to a custom field then you simply need to use the code below to add the link:
<a href="<em><u>hidden link</u></em> field='address'][/types]">Open in Google maps</a>
The [types field='address'][/types] portion is actually a custom field of types. Please change 'address' with the slug of the custom field that you use.
You can find the slug of the custom field, by going to Toolset > Custom Fields, selecting the proper custom field group, and checking the custom field in question. (Check the screenshot)
Also, you can change Open in Google maps with whatever text you want to show in the link.
Thanks.
Thanks Christopher. This is exactly what we need, but, I can't get the address field to pass through properly here. I've attached two screenshots to show what I'm seeing.
The first shows what the code looks like that I've put in the Pop-Up Content box, and the second shows how that's being translated as a link (see the bottom left of the shot for what it looks like).
For some reason it's not properly passing the address through, really frustrating. We are using the custom field simply named "address", just FYI.
Hopefully you can see what's going on in there -- it seems really buggy when trying to add these dynamic fields in to the Pop-up Content box.
Thanks!
Hi there,
I'd appreciate it if you could give me the URL/User/Pass of your WordPress dashboard after you make sure that you have a backup of your website.
It is absolutely important that you give us a guarantee that you have a backup so if something happens you will have a point of restore.
Make sure you set the next reply as private.
Please also tell me which page to check that has the view in question. I might ne able to test that on your instalation.
Thanks.
Hi there,
Thank you for your patience.
I managed to fix the issue that you are having.
The problem is that the Map Pop-up content box can not process a complicated mixture of HTML code and shortcodes.
That is why I used the workaround below:
- Go to "Toolset > Custom Templates".
- Add a custom template, but do not assign it anywhere.
- Add the mixture of the HTML content and shortcodes that you want there,
- Save the template
- In the Maps pop-up content, use the Toolset Fields button at the top and select the custom template that you have crated.
- Save the content and the page that contains the Map.
So from now on, to change the pop-up content you need to edit the custom template.
Thanks.
Thanks Christopher, this is outstanding. I've set up the two different versions we need and have one of them done perfectly, appreciate it!
I do have one issue left, however, for the template now called "Map Popup Content - Region".
In here, at the very top of the popup code, we're supposed to show the POST TITLE WITH A LINK, which is under the Standard WordPress Fields. Unfortunately I don't know how to add this to the code, as I don't see a way to grab the actual HTML from the Pop-up content editor. Do you know what this code needs to be?
Thank you!
Hi there,
If you go to the custom template and click on the current data, you will see that there is a button at the top of the editor that you can use.
Click that button and a pop up will show and you can select the Post with Title link there and it will insert the proper shortcode there. (Please check the screenshots)
I added one so you can see.
If you prefer to add the shortcodes manually, you can find the list of them here:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/
Thank you.