所以我有一个带有'server'和'client'文件夹的Meteor.js项目。在那里,我有一个leaflet.js地图。
在server.js内部我有一个查询只显示某个边界框内的标记。这很好用。我想在移动地图以包含地图的边界框时更新此标记。
./ server / server.js 中的我有一些启动方法:
Meteor.startup(function () {
Meteor.methods({
buildCollections: function() {
Locations = new Meteor.Collection('locations');
Locations._ensureIndex({'geometry.coordinates':'2dsphere'});
},
testStub: function(tst) {
console.log("test stub");
return tst;
},
showBoundingBox: function(mapBox) {
return Locations.find({
'geometry.coordinates': {
$within:{
$box:mapBox
}
}
});
}
});
Meteor.call('buildCollections');
});
服务器在发布集合时调用 showBoundingBox 方法:
Meteor.publish('locations', function() {
mapBox= [ [151.190,-33.94]
,[151.2,-33.84]] ;
return Meteor.call('showBoundingBox',mapBox);
});
这一切都正常,直到我想在移动传单地图时根据地图边界框发送一个不同的边界框:
所以在我的 ./ client / client.js 中我想调用服务器方法来更新可见标记,所以我调用服务器方法:
window.map.on('moveend', function(e) {
var b = window.map.getBounds();
var bounds=[[b._southWest.lng,
b._southWest.lat],
[b._northEast.lng,
b._northEast.lat]
];
Meteor.call('testStub',"echoing back to the client",
function(error,result){
if(error)
{
console.log(error.reason);
}else
{
console.log(result);
}
});
Meteor.call('showBoundingBox',bounds,
function(error,result){
if(error)
{
console.log(error.reason);
}else
{
console.log(result);
}
});
});
现在 testStub 方法将字符串返回给客户端,但 showBoundingBox 方法崩溃了Meteor并出现错误:
Internal exception while processing message{ msg: 'method',
method: 'showBoundingBox',
params: [ [Object], [Object] ] ],
id: 'n' } Maximum call stack size exceeded undefined
其中n是递增的数字索引。
我正在尝试在移动地图时将 $ within 查询更新为一组新坐标。这是一个合法的错误吗?还有另一种方法可以达到这个目的吗?
答案 0 :(得分:0)