On this page本页内容
$center
¶The $center
operator specifies a circle for a $geoWithin
query. The query returns legacy coordinate pairs that are within the bounds of the circle. The operator does not
return GeoJSON objects.
To use the $center
operator, specify an array that contains:
Important
If you use longitude and latitude, specify longitude first.
The query calculates distances using flat (planar) geometry.
Applications can use $center
without having a geospatial index. However, geospatial indexes support much faster queries than the unindexed equivalents.
The following example query returns all documents that have coordinates that exist within the circle centered on [ -74, 40.74 ]
and with a radius of 10
: