i have meteor app using d'burles:google-maps' , 'mdg:geolocation'. have list of places in collection doing geospacial query find places close me, have run on server since mini-mongo not support yet.
i'm publishing , able send , forth parameters narrow search of places, since geolocation takes second user's location, can't subscribe right away, otherwise location null , query won't know do.
i think problem in subscribing,
meteor.subscribe('nearest', mylng, mylat, radius);
here code:
template.map.oncreated(function() { //****if subscribe here, results (if use fixed location, geolocation won't have given me results yet) googlemaps.load(); var self = this; meteor.subscribe('nearest', mylng, mylat, ); googlemaps.ready('map', function(map) { //****if subscribe here, collection count 0 //i need subscribe here since when geolocation provided var marker; console.log(mycollection.find().count()); }); });
this publish, run in server folder:
meteor.publish("nearest", function (lng, lat, dist) { return mycollection.find( {loc: { $geowithin: { $centersphere: [ [ lng, lat ], dist/3963.2 ] } }} ) });
anyone know why second location not subscribing correctly, or know way subscription based on user's location reactively?
i've been searching , searching no luck, appreciated!
Comments
Post a Comment