i'm rather new to Meteor and have a problem, where can't figure out how to solve it.
I want to store dates in a collection. I can pickup the place of the meeting using google maps, which gives me a String with the coordinates. I reverse geocode the coordinates with jaymc:google-reverse-geocode which is basically working (i can console.log the results).
When using Session variables i can output the result, but they keep changing itself. The entrys get there result, then first and second entry change their result, then they change again and so on.
I tried to use ReactiveVar and ReactiveDict but with no result. I can't get any results returned from the reverseGeocode function.
Here's the code:
{{#each termine}}
<div class="listTermine">
<p class="title">{{title}}</p>
<p class="desc">{{desc}}</p>
<p class="location">{{getAddress}}</p>
<p class="dates">
<span class="glyphicon glyphicon-time" aria-hidden="true"></span>
{{formatDate startDate}} bis {{formatDate endDate}}
</p>
</div>
{{/each}}
Template.showTermine.helpers({
getAddress: function() {
var locArray = Termine.findOne({
"title": this.title
}, {
fields: {
locations: 1
}
});
latlngArray = locArray.locations.toString();
var latlong = latlngArray.split(",");
var lat = latlong[0];
var lng = latlong[1];
reverseGeocode.getLocation(lat, lng, function(location) {
Session.set('location', reverseGeocode.getAddrStr());
})
// commented out to prevent infinite loop
//return Session.get('location');
}
});