Mongo GeoJSON:预期位置对象

我试图做一个简单的GeoJSON对象插入到Mongo数据库的操作:

> db.users.ensureIndex({'loc': '2d'}) > db.users.insert({'loc': {'type': 'Point', 'coordinates': [50, 50]}}) location object expected, location array not in correct format 

没有外部的背景 – 这是一个新的数据库和蒙戈壳内的新鲜收集。 我究竟做错了什么?

http://docs.mongodb.org/manual/applications/geospatial-indexes/

说你应该使用2dsphere来使用GeoJSON

 db.users.ensureIndex({'loc': '2dsphere'}) 

你用旧的方法

 db.users.ensureIndex({'loc': '2d'}) 

你必须使用

 db.users.insert({'loc': [50.0, 50.0]})