Reputation: 2006
It's not really clear what should be the unit for $maxDistance
in mongodb geospatial queries.
Here is my code
return await User.find({
location: {
$near: {
$maxDistance: maxDistance, //Is this in Meters or KM?
$geometry: {
type: "Point",
coordinates: [longitude, latitude]
}
}
},
I would love my $maxDistance
to always be in Meters. What should I do?
Thanks.
Upvotes: 0
Views: 269
Reputation: 13500
The search operator $near
uses meters in $maxDistance
and minDistance
.
$maxDistance: <distance in meters>, $minDistance: <distance in meters>
Upvotes: 1