Skip Navigation

[Resolved] [toolset-maps-distance-value…] shortcode not working

This support ticket is created 5 years, 3 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.

Our next available supporter will start replying to tickets in about 0.15 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/Hong_Kong (GMT+08:00)

This topic contains 10 replies, has 2 voices.

Last updated by peterv-5 5 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#1324811

I am trying to... use this:

[wpv-geolocation message_when_missing="<br>We need your location to show this content"]
[toolset-maps-distance-value origin_source='visitor_location' target_source='termmeta' termmeta='wpcf-term-address' termmeta_id='4']
[/wpv-geolocation]

in a view or template and it doesn't display any results.

Issue can be seen here:

hidden link

I expected to see (something like):

2.1 (Miles)

Instead, I got:

Nothing. It is blank.

Further, the display of a single type/entry doesn't display the distance either:

hidden link

#1324821

Hello,

The problem you mentioned above is abnormal, please check these:
1) Follow our document to setup the Google Map API key:
https://toolset.com/documentation/user-guides/display-on-google-maps/creating-a-google-maps-api-key/

2) In case it is a compatibility problem, please deactivate all other plugins, and switch to wordpress default theme 2019, and test again

3) Also check if there is any PHP/JS error in your website:
https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/

4) If the problem still persists, please provide database dump file(ZIP file) of your website, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#1325649

P.S.
I tried each of these PHP versions:

v 5.6
v 7.0
v 7.1

But that didn't effect or change anything that I could tell.

#1325687
distance-value.JPG

Thanks for the details, I can see the problem in your website, and have done below modifications in your website:
1) To get current user's locations, it requires SSL setting in your website:
Dashboard-> Settings-> General
hidden link
Change the WordPress/site URLs from:
hidden link
To:
hidden link

2) Edit the post view "All Holsitic Practitioners":
hidden link
in section "Loop item in All Holsitic Practitioners", display the distance value shortcode, like this:

[toolset-maps-distance-value origin_source='visitor_location' postmeta='wpcf-mapping-address']

Test it in front-end, it works fine, see screenshot distance-value.JPG
hidden link

#1326155

As you can see from my original links in this thread - I was already using HTTPS/SSL.

So I guess I just needed to change:

postmeta='wpcf-address'
to
postmeta='wpcf-mapping-address'

which seems so simple looking at it. But there was no way for me to know that.

May I recommend having MORE coding examples?
The examples here:
https://toolset.com/documentation/user-guides/maps-shortcodes/
are a great start - but clearly if there were just 1 or two more examples, showing a few variations, I probably wouldn't have had to wrap up my entire website and deliver it to you : )

Code examples always surpass any written explanation of how things are supposed to work.

But enough about my problems.
Thank you so much!

I'm so excited because: getting this one piece to work was the final step in proving to my client that we would be able to use ToolSet for our project!

Cheers and have a great day!

#1326191

Large distance discrepancies / Wrong distances

My address (the user address) is 8150 Germone Road.

With the ToolSet/GoogleMapAPI, I'm getting these distances to these locations:

173.9 miles to 101 Main Street, Santa Cruz, CA, USA
48.4 miles to 2049 Main St, Napa, CA 94559
3,809.5 miles to 300 Main Street, East Rochester, New York, USA
2.1 miles to 551 Dufranc Avenue, Sebastopol, CA, USA

However, when I do my own distance mapping using hidden link in a browser, I get these values:

Google Says:
128.9 miles to 101 Main Street, Santa Cruz, CA, USA
39.9 miles to 2049 Main St, Napa, CA 94559
3,737.0 miles to 300 Main Street, East Rochester, New York, USA
2.0 miles to 551 Dufranc Avenue, Sebastopol, CA, USA

The differences are:

45.0
8.5
72.5
0.1

Here's a chart of the differences plus their differences at a percentage of the distance

ToolSet + Google API, google.com/maps, ∆ , ∆ as %

173.9 128.9 45 25.9%
48.4 39.9 8.5 17.6%
3,810 3,737.0 72.5 1.9%
2.1 2 0.1 4.8%

Here are the results on our site:

hidden link

Thoughts?

Thanks in advance.

#1326613

I wasn't clear above:

My address (the user's address) is

8150 Germone Road, Sebastopol, CA 95472

In case you wanted to do some distance calculations from my location.

Thank you.

#1326755

I have tried these in your website:
Edit the post view "All Holsitic Practitioners":
hidden link
in section "Loop item in All Holsitic Practitioners", change the distance shortcode from:

[toolset-maps-distance-value origin_source='visitor_location' postmeta='wpcf-mapping-address' termmeta_id='4']

To:

[toolset-maps-distance-value origin_source='visitor_location' postmeta='wpcf-mapping-address' termmeta_id='4' unit='mi'] miles

Add attribute unit='mi' in above shortcode, see screenshot distance-shortcode.JPG. As you see in the screenshot, you can change the distance unit to mi(default is km)

And the result value is Straight line distance, it should be smaller than values you get from hidden link

More help:
https://toolset.com/documentation/user-guides/maps-shortcodes/#toolset-maps-distance-value
unit. Distance unit.

#1327225

Luo,

Thanks!

There was no example of how to use "unit" on the documentation page. So thanks for sending that!

Is there no way to get driving distance instead "as the crow flies" distance? Who uses just a straight line? Isn't everyone trying to calculate how they would drive/walk/or buss somewhere? Just curious.
I thought that was what the whole google api was about: using their features to gain driving distances.

Please let me know if there is any way to achieve that - but in the meantime. You've been extremely helpful.
I hope some of things you're providing to me can make it to the Documentation pages of this website.

Cheers!

#1327679
distance-shortcode.JPG

For new the questions:
Is there no way to get driving distance instead "as the crow flies" distance? ...

No, there isn't such kind of built-in feature within Toolset maps plugin, you can add a feature request for it, our developers will evaluate it

And the screenshot is missed in my previous answer, I upload it again, you can change the distance unit to mi when you insert the distance shortcode, then there will be shortcode attribute unit='mi', the attribute "unit" is mentioned in the document:
https://toolset.com/documentation/user-guides/maps-shortcodes/#toolset-maps-distance-value

#1333041

My issue is resolved now. Thank you!