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'));
};
Ofcourse,gah我很生氣,因爲錯過了自己。 謝謝 –