Meteorでhtml5ジオロケーションAPIを使用しようとしています。私が使用しているのは:
navigator.geolocation.getCurrentPosition(handle_geolocation_query);
私のjsですが、機能していないようです-Meteorのタイマー(http://docs.meteor.com/#timers)の制限に関連している可能性があります。何かご意見は?
1565 次
1 に答える
2
ありがとう@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');
};
}
于 2012-04-25T06:07:54.743 に答える