Link to home
Start Free TrialLog in
Avatar of dshrenik
dshrenikFlag for United States of America

asked on

Return a value

I'm using Google Maps API to do this
function getDist() {
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix(
  {
    origins: [origin1, origin2],
    destinations: [destinationA, destinationB],
    travelMode: google.maps.TravelMode.DRIVING,
    avoidHighways: false,
    avoidTolls: false
  }, callback);
}

function callback(response, status) {
  // See Parsing the Results for
  // the basics of a callback function.
}

Open in new window


However, I need to return a value from the function getDist(). Please let me know how I can do this. Thanks!
Avatar of nishant joshi
nishant joshi
Flag of India image

might you can use direct calculation

 Math.sqrt((desA-Origin1)*(desA-Origin1)+(desB-Origin2)*(desB-Origin2))

whatever the result is your direct distance.

the formula is use in this is the line equation.....


Regards,
nishant
Avatar of dshrenik

ASKER

I am using the Google Maps API to calculate driving distance.
I have the code that calculates the distance. Its just that I want to return the value rather than just printing it or displaying it in an alert.
ASKER CERTIFIED SOLUTION
Avatar of nishant joshi
nishant joshi
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial