Friday 15 May 2015

javascript - Sort users by distance from current user reactively in Meteor? -



javascript - Sort users by distance from current user reactively in Meteor? -

i have already been facing issues in meteor when dealing reactive sorting of publication according various data. every time, never found real reply trying accomplish , ended giving , deciding "not build app way", makes me sad.

now maybe can phrase problem plenty constructive , interesting answer. think sounds should possible done in meteor app, here is:

i store locations of users in "lat" , "lon" variables in accounts.users collection. want current user list of, say, 10 closest users him or her. how this, considering seemingly complicated set of operations needed distance latitude , longitude?

as far know, pretty much impossible insert such equation in mongodb query condition. how other people accomplish feat?

i appreciate insight on problem, theoretical may be.

look @ working illustration localgeo , sources on github

you can find this:

var nearmarkers = allmarkers.find({ location: { $near: { $geometry: { type: "point", coordinates: location }, $maxdistance: radius } } });

location type of mongodb. , remember: in mongodb lng - first, lat - second, don't know why. on client side, can create publication in same way, depend on radius.

javascript mongodb meteor geolocation distance

No comments:

Post a Comment