Skip to content

Instantly share code, notes, and snippets.

@rahul201992
Created March 4, 2016 17:18
Show Gist options
  • Save rahul201992/935fc065cf1257df1167 to your computer and use it in GitHub Desktop.
Save rahul201992/935fc065cf1257df1167 to your computer and use it in GitHub Desktop.
var distance2 = DISTANCE1.dashboarddistance( 18.5289, 73.8743, 18.558, 73.886,DISTANCE1.callbackFunction);
var finaldistnce= DISTANCE1.dashboarddistance(18.5289, 73.8743, 18.558, 73.886, function(err, distance) {
return distance
});
console.log(finaldistnce);// return null
module.exports = {
dashboarddistance: function(a, b, c, d, callback) {
var ds = 0;
var distance = require('google-distance');
distance.get({
index: 1,
origin: a + ',' + b,
destination: c + ',' + d
}, function(err, data) {
if (err) {
console.log("a");
ds = 0;
return callback(err, ds);
} else {
console.log("b");
ds = data.distance;
return callback(null, ds);
}
});
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment