|
The example for $geoWithin with $center is not correct:
{ $geoWithin : {
|
$center : [x1, y1],
|
$maxDistance : d
|
} }
|
This is not the right syntax for $center. It doesn't support $maxDistance. That is for the $near operator.
Trying this in the shell returns:
> db.docs.find({loc: {$geoWithin: {$center: [15, 15], $maxDistance:10} }})
|
error: {
|
"$err" : "Malformed geo query: { $geoWithin: { $center: [ 15.0, 15.0 ], $maxDistance: 10.0 } }",
|
"code" : 16677
|
}
|
The correct syntax is explained on the $center page:
{ $geoWithin : {
|
$center :
|
[[x, y], radius]
|
} }
|
It is the same as the $centerSphere syntax.
That also works in the shell:
> db.docs.find({loc: {$geoWithin: {$center: [[15, 15], 10]}}})
|
{ "_id" : ObjectId("51cbb33a7645edc3cf1057cb"), "loc" : [ 10, 20 ] }
|
|