blob: f8361dea29a2e4eef4d1a130e968c3db6e05bee3 [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) => {
Matteo Scandolo2c2c8af2016-06-03 15:36:02 -070018 this.selectedEnode = enodes[0];
Matteo Scandolobf7c3662016-06-02 20:30:15 -070019 this.enodes = enodes;
Matteo Scandolobf7c3662016-06-02 20:30:15 -070020 enodes.forEach(node => {
21 const latlng = new google.maps.LatLng(node.GpsCoordinate.Latitude, node.GpsCoordinate.Longitude);
22 bounds.extend(latlng);
23 });
24 return NgMap.getMap();
25 })
26 .then((map) => {
27 map.setCenter(bounds.getCenter());
28 map.fitBounds(bounds);
29 });
30
31 this.showEnodeDetails = (marker, enode) => {
32 this.selectedEnode = enode;
33 };
34 }
35 }
36 });
37}());
38/*global google: false */