【发布时间】:2016-12-06 13:39:02
【问题描述】:
每次我尝试从集合中返回一些数据时,它都会返回一个空数组。我正在使用铁路由器,这是我的代码:
客户:
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'));
};
【问题讨论】:
标签: javascript mongodb meteor meteor-blaze