Commit a43c925b1953fe767cc7c16671e3266b16796590

Authored by Nicolás Guarnieri
Exists in master

Merge branch 'master' into 'master'

Master(efernandez)

See merge request !37
src/js/osm-directive.js
1 angular.module('focaLogisticaPedidoRuta').directive('focaLogistica', function() { 1 angular.module('focaLogisticaPedidoRuta').directive('focaLogistica', 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 contenedor.className = 'border border-light rounded'; 6 contenedor.className = 'border border-light rounded';
7 el.append(contenedor); 7 el.append(contenedor);
8 scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom); 8 scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom);
9 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); 9 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map);
10 }, 10 },
11 controller: ['$scope', '$filter', function($scope, $filter) { 11 controller: ['$scope', '$filter', function($scope, $filter) {
12 $scope.markers = []; 12 $scope.markers = [];
13 $scope.$watch('marcadores', function() { 13 $scope.$watch('marcadores', function() {
14 for(var i in $scope.markers) { 14 for(var i in $scope.markers) {
15 $scope.map.removeLayer($scope.markers[i]); 15 $scope.map.removeLayer($scope.markers[i]);
16 } 16 }
17 $scope.markers = []; 17 $scope.markers = [];
18 18
19 angular.forEach($scope.marcadores, function(marcador) { 19 angular.forEach($scope.marcadores, function(marcador) {
20 var observacion = 20 var observacion =
21 'Vendedor: ' + marcador.notaPedido.idVendedor + ' - ' + 21 'Vendedor: ' + marcador.notaPedido.idVendedor + ' - ' +
22 ( 22 (
23 marcador.notaPedido.vendedor ? 23 marcador.notaPedido.vendedor ?
24 marcador.notaPedido.vendedor.NomVen : 24 marcador.notaPedido.vendedor.NomVen :
25 '' 25 ''
26 ) + '<br/>'; 26 ) + '<br/>';
27 observacion += 'Fecha: ' + 27 observacion += 'Fecha: ' +
28 $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + 28 $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' +
29 marcador.fecha.slice(11,19) + '<br/>'; 29 marcador.fecha.slice(11,19) + '<br/>';
30 observacion += 'Remito Nº: ' + $filter('comprobante')([ 30 observacion += 'Remito Nº: ' + $filter('comprobante')([
31 marcador.notaPedido.remito.sucursal, 31 marcador.notaPedido.remito.sucursal,
32 marcador.notaPedido.remito.numeroRemito 32 marcador.notaPedido.remito.numeroRemito
33 ]) + '<br/>'; 33 ]) + '<br/>';
34 observacion += 'Cliente: ' + 34 observacion += 'Cliente: ' +
35 marcador.notaPedido.cliente.NOM + '<br/>'; 35 marcador.notaPedido.cliente.NOM + '<br/>';
36 36
37 // if($scope.parametros.individual) { 37 // if($scope.parametros.individual) {
38 observacion += 38 observacion +=
39 'Total: ' + $filter('currency')(marcador.notaPedido.remito.total, '$'); 39 'Total: ' + $filter('currency')(marcador.notaPedido.remito.total, '$');
40 observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion; 40 observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion;
41 41
42 if(marcador.distancia) { 42 if(marcador.distancia) {
43 observacion += '<br/>Distancia a casa central: ' + 43 observacion += '<br/>Distancia a casa central: ' +
44 marcador.distancia + 'km'; 44 marcador.distancia + 'km';
45 } 45 }
46 var icon; 46 var icon;
47 if(marcador.notaPedido.remito.idUsuarioProceso) { 47 if(marcador.notaPedido.remito.idUsuarioProceso) {
48 observacion += '<br/>';
49 observacion += '<strong>';
50 observacion += 'Fecha de entrega: ' + marcador.notaPedido.remito
51 .cisternaMovimientos[0].cisternaCarga.fechaReparto.substring(0, 10);
52 observacion += '<br/>';
53 observacion += 'Vehículo: ' + marcador.notaPedido.remito
54 .cisternaMovimientos[0].cisternaCarga.cisterna.vehiculo.tractor;
55 observacion += '<br/>';
56 observacion += 'Transportista: ' + marcador.notaPedido.remito
57 .cisternaMovimientos[0].cisternaCarga.cisterna.vehiculo.transportista
58 .NOM;
59 observacion += '</strong>';
48 //Asignado ROJO 60 //Asignado ROJO
49 icon = new L.Icon({ 61 icon = new L.Icon({
50 iconUrl: 'img/marker-icon-2x-red.png', 62 iconUrl: 'img/marker-icon-2x-red.png',
51 shadowUrl: 'img/marker-shadow.png', 63 shadowUrl: 'img/marker-shadow.png',
52 iconSize: [25, 41], 64 iconSize: [25, 41],
53 iconAnchor: [12, 41], 65 iconAnchor: [12, 41],
54 popupAnchor: [1, -34], 66 popupAnchor: [1, -34],
55 shadowSize: [41, 41] 67 shadowSize: [41, 41]
56 }); 68 });
57 }else { 69 }else {
58 observacion += '<br/>'; 70 observacion += '<br/>';
59 observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+ 71 observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+
60 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+ 72 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+
61 JSON.stringify(marcador)+')\' draggable="true"></i>(Arrastrar icono)'; 73 JSON.stringify(marcador)+')\' draggable="true"></i>(Arrastrar icono)';
74
62 //Sin asignar VERDE 75 //Sin asignar VERDE
63 icon = new L.Icon({ 76 icon = new L.Icon({
64 iconUrl: 'img/marker-icon-2x-green.png', 77 iconUrl: 'img/marker-icon-2x-green.png',
65 shadowUrl: 'img/marker-shadow.png', 78 shadowUrl: 'img/marker-shadow.png',
66 iconSize: [25, 41], 79 iconSize: [25, 41],
67 iconAnchor: [12, 41], 80 iconAnchor: [12, 41],
68 popupAnchor: [1, -34], 81 popupAnchor: [1, -34],
69 shadowSize: [41, 41] 82 shadowSize: [41, 41]
70 }); 83 });
71 } 84 }
72 $scope.markers.push( 85 $scope.markers.push(
73 L.marker( 86 L.marker(
74 [marcador.latitud, marcador.longitud], {icon: icon}) 87 [marcador.latitud, marcador.longitud], {icon: icon})
75 .addTo($scope.map) 88 .addTo($scope.map)
76 .bindPopup(observacion) 89 .bindPopup(observacion)
77 .bindTooltip('Haga click para seleccionar') 90 .bindTooltip('Haga click para seleccionar')
78 ); 91 );
79 //abre marcador del primer punto 92 //abre marcador del primer punto
80 //$scope.markers[0].openPopup(); 93 //$scope.markers[0].openPopup();
81 }); 94 });
82 }); 95 });
83 }], 96 }],
84 scope: { 97 scope: {
85 latitud: '=', 98 latitud: '=',
86 longitud: '=', 99 longitud: '=',
87 zoom: '=', 100 zoom: '=',
88 marcadores: '=', 101 marcadores: '=',
89 parametros: '=' 102 parametros: '='
90 } 103 }
91 }; 104 };
92 }); 105 });
93 106