-
Notifications
You must be signed in to change notification settings - Fork 0
/
maps2.js
33 lines (28 loc) · 816 Bytes
/
maps2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Places = new Meteor.Collection("places");
if (Meteor.isClient) {
Deps.autorun(function() {
gmaps.clearMarker();
var pos = Places.find({},{sort: {date: -1}});
pos.forEach(function (position) {
console.log("add " + position.lat + position.lng);
gmaps.addMarker(position.lat, position.lng);
});
});
Template.map.rendered = function() {
if(!this.rendered){
console.log("init");
gmaps.initialize();
gmaps.clearMarker();
var pos = Places.find({},{sort: {date: -1}, /*limit:1*/});
pos.forEach(function (position) {
gmaps.addMarker(position.lat, position.lng);
});
this.rendered = true;
}
}
}
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
});
}