Skip to content

Commit

Permalink
Initial adding of map markers.
Browse files Browse the repository at this point in the history
Ruslan Kabalin authored and kabalin committed Feb 3, 2019
1 parent 6889420 commit 6449bf7
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion client/templates/locations/locations_page.js
Original file line number Diff line number Diff line change
@@ -51,6 +51,8 @@ Template.locationsPage.onCreated(function() {
libraries: 'places'
});

var markers = {};

var instance = this;

// Init reactive var.
@@ -60,7 +62,21 @@ Template.locationsPage.onCreated(function() {
// Subscribe to the locations publication.
var subscription = instance.subscribe('locations', instance.mapBoundsCoordinates.get());
if (subscription.ready()) {
console.log(instance.locations().count());
if (instance.locations().count()) {
var map = instance.$('.search-locations-input').geocomplete("map");
instance.locations().forEach(function(location) {
if (!markers[location._id]) {
var latLng = new google.maps.LatLng(location.location.coordinates[1], location.location.coordinates[0]);
var marker = new google.maps.Marker({
position: latLng,
map: map,
title: 'Hello World!',
id: location._id
});
markers[location._id] = marker;
}
});
}
}
});
// Locations cursor.

0 comments on commit 6449bf7

Please sign in to comment.