Geo location query using DB api and mongo db


has anyone query spacial data using mongo db and the db api?


Hi Jose

just put the following as a filter.

{“loc”: {"$near" : {"$geometry": {“type” : “Point”, “coordinates” : [lng,lat] }, “spherical” : “true” } }}

you should of course create a geo index in mongodb as follow:
db.collection.createIndexes( { loc: “2dsphere”})
where collection is the name of your mongodb collection (position in this example)

example of a Document in Position Collection:

"_id": ObjectId(“564a0db640da6a430ffbb851”),
“owner”: "",
“ville”: “toronto”,
“loc”: [

“comment”: “test toronto”

let me know if you need more help