Commit 960bd05b6b3c650d732a56f8479737f5fe4dd83a

Authored by Eric Fernandez
1 parent ce06ed3998
Exists in master

espacios

Showing 1 changed file with 3 additions and 3 deletions   Show diff stats
src/js/osm-directive.js
1 angular.module('focaLogisticaPedidoRuta').directive('foca', function() { 1 angular.module('focaLogisticaPedidoRuta').directive('foca', function() {
2 return { 2 return {
3 restrict: 'E', 3 restrict: 'E',
4 link: function(scope, el, attrs) { 4 link: function(scope, el, attrs) {
5 var contenedor = document.createElement('div'); 5 var contenedor = document.createElement('div');
6 el.append(contenedor); 6 el.append(contenedor);
7 scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom); 7 scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom);
8 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); 8 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map);
9 }, 9 },
10 controller: ['$scope', '$filter', function($scope, $filter) { 10 controller: ['$scope', '$filter', function($scope, $filter) {
11 $scope.markers = []; 11 $scope.markers = [];
12 $scope.$watch('marcadores', function() { 12 $scope.$watch('marcadores', function() {
13 for(var i in $scope.markers) { 13 for(var i in $scope.markers) {
14 $scope.map.removeLayer($scope.markers[i]); 14 $scope.map.removeLayer($scope.markers[i]);
15 } 15 }
16 $scope.markers = []; 16 $scope.markers = [];
17 17
18 angular.forEach($scope.marcadores, function(marcador) { 18 angular.forEach($scope.marcadores, function(marcador) {
19 var observacion = 19 var observacion =
20 'Vendedor: ' + marcador.notaPedido.idVendedor + ' - ' + 20 'Vendedor: ' + marcador.notaPedido.idVendedor + ' - ' +
21 ( 21 (
22 marcador.notaPedido.vendedor ? 22 marcador.notaPedido.vendedor ?
23 marcador.notaPedido.vendedor.NomVen : 23 marcador.notaPedido.vendedor.NomVen :
24 '' 24 ''
25 ) + '<br/>'; 25 ) + '<br/>';
26 observacion += 'Fecha: ' + 26 observacion += 'Fecha: ' +
27 $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + 27 $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' +
28 marcador.fecha.slice(11,19) + '<br/>'; 28 marcador.fecha.slice(11,19) + '<br/>';
29 observacion += 'Nº: ' + $filter('comprobante')([ 29 observacion += 'Nº: ' + $filter('comprobante')([
30 marcador.notaPedido.sucursal, 30 marcador.notaPedido.sucursal,
31 marcador.notaPedido.numeroNotaPedido 31 marcador.notaPedido.numeroNotaPedido
32 ]) + '<br/>'; 32 ]) + '<br/>';
33 observacion += 'Cliente: ' + 33 observacion += 'Cliente: ' +
34 marcador.notaPedido.cliente.NOM + '<br/>'; 34 marcador.notaPedido.cliente.NOM + '<br/>';
35 35
36 if ($scope.parametros.individual) { 36 if($scope.parametros.individual) {
37 observacion += 37 observacion +=
38 'Total: ' + $filter('currency')(marcador.notaPedido.total, '$'); 38 'Total: ' + $filter('currency')(marcador.notaPedido.total, '$');
39 observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion; 39 observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion;
40 40
41 if (marcador.distancia) { 41 if(marcador.distancia) {
42 observacion += '<br/>Distancia a casa central: ' + 42 observacion += '<br/>Distancia a casa central: ' +
43 marcador.distancia + 'km'; 43 marcador.distancia + 'km';
44 } 44 }
45 } else { 45 }else {
46 observacion += 'Cantidad de nota de pedido: ' + 46 observacion += 'Cantidad de nota de pedido: ' +
47 marcador.cantidad + '<br/>'; 47 marcador.cantidad + '<br/>';
48 observacion += 'Total Vendido: ' + 48 observacion += 'Total Vendido: ' +
49 $filter('currency')(marcador.total, '$'); 49 $filter('currency')(marcador.total, '$');
50 } 50 }
51 observacion += '<br/>'; 51 observacion += '<br/>';
52 observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+ 52 observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+
53 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+ 53 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+
54 JSON.stringify(marcador)+')\' draggable="true"></i>'; 54 JSON.stringify(marcador)+')\' draggable="true"></i>';
55 $scope.markers.push( 55 $scope.markers.push(
56 L.marker([marcador.latitud, marcador.longitud]).addTo($scope.map) 56 L.marker([marcador.latitud, marcador.longitud]).addTo($scope.map)
57 .bindPopup(observacion) 57 .bindPopup(observacion)
58 ); 58 );
59 59
60 $scope.markers[0].openPopup(); 60 $scope.markers[0].openPopup();
61 }); 61 });
62 }); 62 });
63 }], 63 }],
64 scope: { 64 scope: {
65 latitud: '=', 65 latitud: '=',
66 longitud: '=', 66 longitud: '=',
67 zoom: '=', 67 zoom: '=',
68 marcadores: '=', 68 marcadores: '=',
69 parametros: '=' 69 parametros: '='
70 } 70 }
71 }; 71 };
72 }); 72 });
73 73