UPDATE: I have gotten each post to stash the lng/lat location of the device it was created from. I am now having trouble display only posts within x miles of the devices current location. Here is updated detailed description of current issue:
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.
This is from a function, Geolocation.latLng();, which prints out the object with the lat and lng of the current device.
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.
Here is my current function which lists all the post from my database.
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};
}
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.
I imagine I use an if statement of some sort or maybe a filer when I am finding the posts in the Yaks collection?
Does any one have any idea on how I can filter the collection of posts to do something similar to this?
If i need to post up more code to make it easier to understand my question please let me know and I will.
Thanks again to any one who helps out!
ORIGINAL: I am wondering if any one has any experience using this plugin for Meteor JS: Meteor Geolocation Package(https://github.com/meteor/mobile-packages/blob/master/packages/mdg:geolocation/README.md) with their app in order to display data that was posted at a location near the current user(similar to how yik yak works)?
If you have experience with this could you please explain to me how would one go about doing something similar to this? Are there any tutorials or posts about this same kind of thing you can refer me to?
Looking at the plugin documentation there doesn’t seem to be much information on how to do something similar to this so I would greatly appreciate any insight any of you may have on this issue.
Thanks in advanced to any one helps out!