Based on MongoDB 2.6
GeoJSON format
{"type": "Point", "coordinates": [Lon (longitude), lat (latitude)]}
Test data
Db.point.test.insert ({"Address": "Nanjing Lukou International Airport", "Loc": {"type": "Point", "coordinates": [118.783799,31.979234]}}) Db.point.test.insert ({"Address": "Nanjing Pukou Park", "Loc": {"type": "Point", "coordinates": [118.639523,32.070078]}}) Db.point.test.insert ({"Address": "Nanjing railway Station", "Loc": {"type": "Point", "coordinates": [118.803032,32.09248]}}) Db.point.test.insert ({"Address": "Nanjing Xinjiekou", "loc": {"type": "Point", "coordinates": [118.790611,32.047616]}}) Db.point.test.insert ({"Address": "Nanjing Zhang Fu Yuan", "loc": {"type": "Point", "coordinates": [118.790427,32.03722]}}) Db.point.test.insert ({"Address": "Nanjing Sanshan Street", "Loc": {"type": "Point", "coordinates": [118.788135,32.029064]}}) Db.point.test.insert ({"Address": "Nanjing Zhonghua Gate", "loc": {"type": "Point", "coordinates": [118.781161,32.013023]}}) Db.point.test.insert ({"Address": "Nanjing Ender Gate", "loc": {"type": "Point", "coordinates": [118.768964,31.99646]}})
Be sure to index
Db.point.test.ensureIndex ({loc: "2dsphere"})
Retrieve data within a specified radius (in meters)
{loc:{$near: {$geometry: {type: ' point ', coordinates: [118.783799,31.979234]}, $maxDistance: 5000}}} data within//5000 m
MongoDB spatial positioning (point) and distance retrieval