Commit 63066925868da0f151a80f3fefe1ed6ba3e9858a

Authored by Eric Fernandez
Exists in master and in 1 other branch develop

Merge branch 'master' into 'master'

Master

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