HTML5 getCurrentPosition与流星
问题描述:
我想与流星一起使用html5地理定位api。 我使用: navigator.geolocation.getCurrentPosition(handle_geolocation_query);
在我的js,但它似乎并没有工作 - 我想这可能与计时器(http://docs.meteor.com/#timers)限制流星有关。有什么想法吗?HTML5 getCurrentPosition与流星
答
感谢@lashleigh这是一个装载问题
这里是为我工作,我不能想到的代码(我使用Modernizr.js检测地理位置)
if (Meteor.is_client) {
Session.set('loc','?');
//alert(Modernizr.geolocation);
function foundLocation(location) {
console.log(location);
Session.set('loc','lat: '+location.coords.latitude+', lan: '+ location.coords.longitude);
}
function noLocation() {
alert('no location');
}
Template.hello.greeting = function() {
var output;
if (Modernizr.geolocation) {
navigator.geolocation.getCurrentPosition(foundLocation, noLocation);
outpout = Session.get('loc');
}
return Session.get('loc');
};
}
+0
甜!我很高兴你能解决它。 – lashleigh 2012-04-26 06:20:56
这些会冲突的原因。我刚刚在我的流星应用程序中测试了地理定位,以确保一切正常。你怎么处理这个处理程序?可能是处理程序试图访问尚未完成加载的数据。 – lashleigh 2012-04-24 04:56:58