From 6449bf77fc53b6c2213569cbcd44f8997cbf5c90 Mon Sep 17 00:00:00 2001 From: Ruslan Kabalin Date: Fri, 5 Jun 2015 22:04:57 +0100 Subject: [PATCH] Initial adding of map markers. --- client/templates/locations/locations_page.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/client/templates/locations/locations_page.js b/client/templates/locations/locations_page.js index 06cd480..7467654 100644 --- a/client/templates/locations/locations_page.js +++ b/client/templates/locations/locations_page.js @@ -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.