【发布时间】:2016-11-26 09:49:39
【问题描述】:
我的问题是搜索并显示某个仪表附近的所有注册用户。在谷歌搜索了很多但没有找到好的解决方案后,我开始编写非常简单的代码(我使用 mdg:geolocation)。
main.js
// in the client side
Template.localPosition.helpers({
'getLocalPosition': function(){
var currentUserId = Meteor.userId();
if( currentUserId ) {
var localPos = Geolocation.latLng();
return "LAT:" + localPos.lat + " LNG:" + localPos.lng;
}
}
});
在 main.html 中,我显示了一个带有 {{getLocalPosition}} 调用的“localPosition”模板。它可以工作,但在控制台面板中我有:
模板助手中的异常:TypeError:无法读取 null 的属性 'lat'
这是为什么?
【问题讨论】:
-
能否请您显示正文的其余部分 html 代码?
-
我已将解决方案编辑回滚到您的问题,因为我们希望在这里为未来的读者保留问题。请在下面的答案框中添加您的答案,谢谢。
标签: mongodb meteor geolocation