Matteo Scandolo | bf7c366 | 2016-06-02 20:30:15 -0700 | [diff] [blame] | 1 | /*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 Scandolo | 2c2c8af | 2016-06-03 15:36:02 -0700 | [diff] [blame] | 18 | this.selectedEnode = enodes[0]; |
Matteo Scandolo | bf7c366 | 2016-06-02 20:30:15 -0700 | [diff] [blame] | 19 | this.enodes = enodes; |
Matteo Scandolo | bf7c366 | 2016-06-02 20:30:15 -0700 | [diff] [blame] | 20 | 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 */ |