blob: b3818e73ced7b4855d4bd60662dacd20f3cf0700 [file] [log] [blame]
Matteo Scandolobf7c3662016-06-02 20:30:15 -07001/*global google: true */
2(function () {
3 'use strict';
4
5 angular.module('mCord')
Matteo Scandolobe342fa2016-06-08 15:54:55 -07006 .directive('eNodeMap', function ($uibModal) {
Matteo Scandolobf7c3662016-06-02 20:30:15 -07007 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
Matteo Scandoloe0e4de42016-06-08 16:15:30 -070014 let bounds;
Matteo Scandolobf7c3662016-06-02 20:30:15 -070015
16 Enodeb.query().$promise
17 .then((enodes) => {
Matteo Scandoloe0e4de42016-06-08 16:15:30 -070018 console.log('loaded enodes for map');
Matteo Scandolobf7c3662016-06-02 20:30:15 -070019 this.enodes = enodes;
Matteo Scandoloe0e4de42016-06-08 16:15:30 -070020 bounds = new google.maps.LatLngBounds();
Matteo Scandolobf7c3662016-06-02 20:30:15 -070021 enodes.forEach(node => {
22 const latlng = new google.maps.LatLng(node.GpsCoordinate.Latitude, node.GpsCoordinate.Longitude);
23 bounds.extend(latlng);
24 });
25 return NgMap.getMap();
26 })
27 .then((map) => {
28 map.setCenter(bounds.getCenter());
29 map.fitBounds(bounds);
30 });
31
32 this.showEnodeDetails = (marker, enode) => {
33 this.selectedEnode = enode;
34 };
Matteo Scandolobe342fa2016-06-08 15:54:55 -070035 this.addEnode = () => {
36 this.modalInstance = $uibModal.open({
37 animation: true,
38 templateUrl: 'addEnode',
39 controllerAs: 'vm',
40 controller: function($uibModalInstance){
41 this.modal = $uibModalInstance;
42 }
43 });
44 }
Matteo Scandolobf7c3662016-06-02 20:30:15 -070045 }
46 }
47 });
48}());
49/*global google: false */