Commit c7268e6fb0308cdaa315bc0f515b434dfb761108

Authored by Eric Fernandez
1 parent acb9dc7e2c
Exists in master

no abre popup

Showing 1 changed file with 2 additions and 2 deletions   Show diff stats
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 observacion += '<br/>'; 46 observacion += '<br/>';
47 observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+ 47 observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+
48 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+ 48 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+
49 JSON.stringify(marcador)+')\' draggable="true"></i>(Arrastrar icono)'; 49 JSON.stringify(marcador)+')\' draggable="true"></i>(Arrastrar icono)';
50 var icon; 50 var icon;
51 if(marcador.notaPedido.remito.idUsuarioProceso) { 51 if(marcador.notaPedido.remito.idUsuarioProceso) {
52 //Asignado ROJO 52 //Asignado ROJO
53 icon = new L.Icon({ 53 icon = new L.Icon({
54 iconUrl: 'img/marker-icon-2x-red.png', 54 iconUrl: 'img/marker-icon-2x-red.png',
55 shadowUrl: 'img/marker-shadow.png', 55 shadowUrl: 'img/marker-shadow.png',
56 iconSize: [25, 41], 56 iconSize: [25, 41],
57 iconAnchor: [12, 41], 57 iconAnchor: [12, 41],
58 popupAnchor: [1, -34], 58 popupAnchor: [1, -34],
59 shadowSize: [41, 41] 59 shadowSize: [41, 41]
60 }); 60 });
61 }else { 61 }else {
62 //Sin asignar VERDE 62 //Sin asignar VERDE
63 icon = new L.Icon({ 63 icon = new L.Icon({
64 iconUrl: 'img/marker-icon-2x-green.png', 64 iconUrl: 'img/marker-icon-2x-green.png',
65 shadowUrl: 'img/marker-shadow.png', 65 shadowUrl: 'img/marker-shadow.png',
66 iconSize: [25, 41], 66 iconSize: [25, 41],
67 iconAnchor: [12, 41], 67 iconAnchor: [12, 41],
68 popupAnchor: [1, -34], 68 popupAnchor: [1, -34],
69 shadowSize: [41, 41] 69 shadowSize: [41, 41]
70 }); 70 });
71 } 71 }
72 $scope.markers.push( 72 $scope.markers.push(
73 L.marker([marcador.latitud, marcador.longitud], {icon: icon}) 73 L.marker([marcador.latitud, marcador.longitud], {icon: icon})
74 .addTo($scope.map) 74 .addTo($scope.map)
75 .bindPopup(observacion) 75 .bindPopup(observacion)
76 ); 76 );
77 77 //abre marcador del primer punto
78 $scope.markers[0].openPopup(); 78 //$scope.markers[0].openPopup();
79 }); 79 });
80 }); 80 });
81 }], 81 }],
82 scope: { 82 scope: {
83 latitud: '=', 83 latitud: '=',
84 longitud: '=', 84 longitud: '=',
85 zoom: '=', 85 zoom: '=',
86 marcadores: '=', 86 marcadores: '=',
87 parametros: '=' 87 parametros: '='
88 } 88 }
89 }; 89 };
90 }); 90 });
91 91