blob: 05b5e7e8d46da80c98c5d139b4fa591247d04b37 [file] [log] [blame]
Matteo Scandolobf7c3662016-06-02 20:30:15 -07001/*global google: true */
2(function () {
3 'use strict';
4
5 angular.module('mCord')
6 .directive('eNodeMap', function () {
7 return {
8 restrict: 'E',
9 scope: {},
10 controllerAs: 'vm',
11 templateUrl: 'app/view/home/e-node-map.tpl.html',
12 controller: function($log, Enodeb, NgMap){
13
14 let bounds = new google.maps.LatLngBounds();
15
16 Enodeb.query().$promise
17 .then((enodes) => {
18 this.enodes = enodes;
Matteo Scandolobf7c3662016-06-02 20:30:15 -070019 enodes.forEach(node => {
20 const latlng = new google.maps.LatLng(node.GpsCoordinate.Latitude, node.GpsCoordinate.Longitude);
21 bounds.extend(latlng);
22 });
23 return NgMap.getMap();
24 })
25 .then((map) => {
26 map.setCenter(bounds.getCenter());
27 map.fitBounds(bounds);
28 });
29
30 this.showEnodeDetails = (marker, enode) => {
31 this.selectedEnode = enode;
32 };
33 }
34 }
35 });
36}());
37/*global google: false */