I'm unable to use the geoNear function in my nodeJS application.
Ninja.aggregate([
{
$geoNear: {
near: {
type: "Point",
coordinates: [parseFloat(req.query.lng), parseFloat(req.query.lat)]
},
distanceField: "dist.calculated",
spherical: true,
maxDistance: 100000
}
}
])
.then(function (ninja) {
res.send(ninja);
}).catch(next);
Error obatined: { "error": "geo near accepts just one argument when querying for a GeoJSON point. Extra field found: $maxDistance: 100000.0" }
Please check your input values for req.query.lng, req.query.lat Keep coordinates as [longitude, latitude]
where, LONGITUDE ranges from -180 to 180, LATITUDE ranges from -90 to 90 Please make sure you have received valid latitude and longitude