HTML5 getCurrentPosition with Meteor

I am trying to use html5 geolocation api with Meteor. I use: navigator.geolocation.getCurrentPosition(handle_geolocation_query);in my js, but it doesn't seem to work - I think it could be due to the timer ( http://docs.meteor.com/#timers ) there are Meteor restrictions. Any thoughts?

+3
source share
1 answer

Thanks @lashleigh, it was a download problem

Here is the code that worked for me (I use Modernizr.js to detect geolocation)

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');
  };
}
+2
source

All Articles