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) => { |
| 18 | this.enodes = enodes; |
Matteo Scandolo | bf7c366 | 2016-06-02 20:30:15 -0700 | [diff] [blame] | 19 | 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 */ |