| this file is example.js:= 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); | ||||||||||||||||||
| } | ||||||||||||||||||
| }); | ||||||||||||||||||
| }, | ||||||||||||||||||
};
main.js file this :=
|