title: MeteorJS: Display Posts with locations within x miles of current location
body: <p>I am working on an application that will display the posts of people within a certain amount of distance of their location.</p>
  
  <p>Whenever a post is created a value of location is created which is stored with: {"lat":39.7230949,"lng":-104.83521619999999}. The lat and longitude of the current location when the post was made.</p>
  
  <p>This is from a function, Geolocation.latLng();, which prints out the object with the lat and lng of the current device.</p>
  
  <p>I am now trying to figure out how to have the page which lists all the post, only show post that fall within a radius of the devices current location.</p>
  
  <p>Here is my current function which lists all the post from my database.</p>
  
  <pre><code>Template.yakResults.searchResults = function () {
      var keyword  = Session.get("search-query");
      var query = new RegExp( keyword, 'i' );
      var results = Yaks.find( { $or: [{'yak': query}] }, {sort: {score: -1}});
      return {results: results};
  }
  </code></pre>
  
  <p>What do I have to do to get the results to be with say 10 mile radius of the devices current long/lat which can be found with the function mentioned above.</p>
  
  <p>I imagine I use an if statement of some sort or maybe a filer when I am finding the posts in the Yaks collection?</p>
  
  <p>Does any one have any idea on how I can filter the collection of posts to do something similar to this?</p>
  
  <p>If i need to post up more code to make it easier to understand my question please let me know and I will.</p>