getting-MEAN icon indicating copy to clipboard operation
getting-MEAN copied to clipboard

Chapter 07- geoNear library doesn't work properly

Open rashmitpankhania opened this issue 7 years ago • 1 comments

rashmitpankhania avatar May 23 '18 18:05 rashmitpankhania

Hello i changed the locationsListByDistance function in app_api\controllers\location.js Delete the old Loc.geoNear function and added Loc.aggregate function. In this method you don't need buildLocationList func. anymore because aggregate calculates the distance by itself. ... Loc .aggregate([{ $geoNear: { near: point, maxDistance: theEarth.getRadsFromDistance(maxDistance), includeLocs: "dist.location", distanceField: "dist.calculated", spherical: true, num: 10 } }]) .limit(20) .exec((err, results) => { if (err) { res .status(400) .json(err) } else { res .status(200) .json(results); } }); ...

hkh85 avatar Oct 10 '18 15:10 hkh85