Posted by mukwenhac on February 8, 2012 at 7:21am
2 followers
Jump to:
| Project: | Get Directions |
| Version: | 7.x-2.0 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
Hi guys,
I have my get redirections configured to show up in a colorbox.
People can calculate distance, etc...i wanted to know how I may retrieve the calculated value for distance.
I would want this sent with a webform data if that's possible (so maybe if it can be stored in a global variable/url argument maybe??) I'm a newbie at coding so if i'd like to know the best implementation.
Thanks.
Comments
#1
What Getdirections does is provide a map with a form, once that is loaded it does not communicate with the server anymore. All the interactions are managed by the javascript in one of the files
getdirections_v3a.js
getdirections_v3b.js
getdirections_v3.js
Which one depends on which settings you have selected.
The javascript function that calculates Distance and Duration is function computeTotals(), which puts the calculated result in a div with id "getdirections_show_distance"
You would need to modify that to send the data back to the server using jQuery's $.get() function and you would need a php function to receive that data (presumably in a bespoke module), store it somewhere so that it would be available to whatever you want to do with it thereafter. You would also need to find a way to identify each session so that the data is stored uniquely, cookies might be a way to do that.
Alternately it might be possible to write your own javascript which monitors #getdirections_show_distance and returns it's content to the server, that way you avoid hacking Getdirections so you don't have to worry about updates overwriting your changes.
Although this is probably doable it would require a good understanding of jQuery and enough php programming skills to write a bespoke module to act as 'glue' between the various bits you want to join together.