Commit 89b5f90e006b7a54b5d851f7fe45482cf685f2fd
1 parent
af8b463fb4
Exists in
develop
Change
Codigo identado
Showing
1 changed file
with
43 additions
and
46 deletions
Show diff stats
src/js/controller.js
1 | angular.module('focaModalLocalizar') | 1 | angular.module('focaModalLocalizar') |
2 | .controller('focaModalLocalizarController', | 2 | .controller('focaModalLocalizarController', |
3 | [ | 3 | [ |
4 | '$scope', | 4 | '$scope', '$uibModalInstance', 'focaModalLocalizarService', |
5 | '$uibModalInstance', | 5 | 'focaModalService', 'parametros', |
6 | 'focaModalLocalizarService', | 6 | function ($scope, $uibModalInstance, focaModalLocalizarService, |
7 | 'focaModalService', | 7 | focaModalService, parametros) { |
8 | 'parametros', | ||
9 | function($scope, $uibModalInstance, | ||
10 | focaModalLocalizarService, focaModalService, parametros) { | ||
11 | 8 | ||
12 | $scope.latitud = parametros.latitud || -32.89214159952345; | 9 | $scope.latitud = parametros.latitud || -32.89214159952345; |
13 | $scope.longitud = parametros.longitud || -68.84572999101856; | 10 | $scope.longitud = parametros.longitud || -68.84572999101856; |
14 | $scope.localizar = !! parametros.direccion; | 11 | $scope.localizar = !!parametros.direccion; |
15 | 12 | ||
16 | if (parametros.direccion) { | 13 | if (parametros.direccion) { |
17 | focaModalLocalizarService | 14 | focaModalLocalizarService |
18 | .getLatLng({ | 15 | .getLatLng({ |
19 | street: parametros.direccion.numero + ' ' + parametros.direccion.calle, | 16 | street: parametros.direccion.numero + ' ' + parametros.direccion.calle, |
20 | country: 'Argentina', | 17 | country: 'Argentina', |
21 | city: parametros.direccion.provincia, | 18 | city: parametros.direccion.provincia, |
22 | county: parametros.direccion.localidad, | 19 | county: parametros.direccion.localidad, |
23 | format: 'json' | 20 | format: 'json' |
24 | }) | 21 | }) |
25 | .then(function(res) { | 22 | .then(function (res) { |
26 | if (res.data.length) { | 23 | if (res.data.length) { |
27 | $scope.latitud = res.data[0].lat; | 24 | $scope.latitud = res.data[0].lat; |
28 | $scope.longitud = res.data[0].lon; | 25 | $scope.longitud = res.data[0].lon; |
29 | $scope.$broadcast('moveMap', { | 26 | $scope.$broadcast('moveMap', { |
30 | latitud: $scope.latitud, | 27 | latitud: $scope.latitud, |
31 | longitud: $scope.longitud | 28 | longitud: $scope.longitud |
32 | }); | 29 | }); |
33 | } else { | 30 | } else { |
34 | focaModalService.alert('No se pudo localizar el domicilio'); | 31 | focaModalService.alert('No se pudo localizar el domicilio'); |
35 | } | 32 | } |
36 | }); | 33 | }); |
37 | } | 34 | } |
38 | 35 | ||
39 | $scope.cancel = function() { | 36 | $scope.cancel = function () { |
40 | $uibModalInstance.dismiss(); | 37 | $uibModalInstance.dismiss(); |
41 | }; | 38 | }; |
42 | 39 | ||
43 | $scope.aceptar = function() { | 40 | $scope.aceptar = function () { |
44 | $uibModalInstance.close({ | 41 | $uibModalInstance.close({ |
45 | latitud: $scope.latitud, | 42 | latitud: $scope.latitud, |
46 | longitud: $scope.longitud | 43 | longitud: $scope.longitud |
47 | }); | 44 | }); |
48 | }; | 45 | }; |
49 | } | 46 | } |
50 | ] | 47 | ] |
51 | ); | 48 | ); |
52 | 49 |