原因:需要为坐标建立索引, 坐标值要为 double 型。
db.places.ensureIndex({ "location": "2d" } )
'location' => ['lng'=>42.241,'lat'=>55.5],
$mongo->db->places->find(
'location'=>[
'$geoWithin'=>['$centerSphere'=>[[floatval($lng), floatval($lat)], 1/3959]]
]
)
原因:需要为坐标建立索引, 坐标值要为 double 型。
db.places.ensureIndex({ "location": "2d" } )
'location' => ['lng'=>42.241,'lat'=>55.5],
$mongo->db->places->find(
'location'=>[
'$geoWithin'=>['$centerSphere'=>[[floatval($lng), floatval($lat)], 1/3959]]
]
)