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