2012-04-21 6 views
3

私はMeteorでhtml5ジオロケーションAPIを使用しようとしています。 私は使用しています: navigator.geolocation.getCurrentPosition(handle_geolocation_query);私のjsでも動作していないようです - 私はそれがタイマー(http://docs.meteor.com/#timers)制限に関連していると思う流星があります。何かご意見は?HTML5 getCurrentPosition with Meteor

+0

私は考えることができませんこれらが衝突する理由。私は今流星のアプリで地理位置をテストして、確かにすべてがうまくいきました。ハンドラーで何をしていますか?ハンドラがロード完了していないデータにアクセスしようとしている可能性があります。 – lashleigh

答えて

2

それはここでロード問題

だった(私は地理的な位置を検出するためのModernizr.jsを使用しています)私のために働いていたコードがある@lashleighおかげ

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