2016-08-01 4 views
1

コレクションからデータを返そうとするたびに空の配列が返されます。私は鉄のルータを使用していますし、これは私のコードです:

クライアント:

Meteor.call('insertEvent', { 
    "eventLoc": { 
     "type" : "Point", 
     "coordinates": [ 
      eventLongitude, 
      eventLatitude 
     ]} 
} 

function getBox() { 
var bounds = GoogleMaps.maps.mapSeek.instance.getBounds(); 
var ne = bounds.getNorthEast(); 
var sw = bounds.getSouthWest(); 
    Session.set('box', [[sw.lat(),sw.lng()],[ne.lat(),ne.lng()]]); 
} 

getbox(); 

サーバー:

Meteor.publish('publicPlaces', function(box) { 
var find = { 
    eventLoc: { 
     $geoWithin: { 
      $box: box 
     } 
    } 
}; 

return Events.find(find); 
}); 

ルート:

Router.route('/seek', function() { 
    this.render('seek'); 
    Meteor.subscribe('publicPlaces', Session.get('box')); 
}; 

答えて

2

私が思うに、エラーがでていますbox値です。 MongoDBのマニュアルによると、最初に経度を指定しなければならず、コードSession.set('box', [[sw.lat(),sw.lng()],[ne.lat(),ne.lng()]]);は逆にするようです。

+0

もちろん、私はそれを見逃して自分自身に怒っている。 ありがとう –

関連する問題