Commit 42170accf55e56a5b51acd87c65a6e3e94363c43

Authored by Jose Pinto
Exists in master

Merge branch 'master' into 'master'

Master

See merge request !7
src/js/osm-directive.js
1 angular.module('focaLogisticaPedidoRuta').directive('osmPuntoDescarga', function() { 1 angular.module('focaModalPuntoDescarga').directive('osmPuntoDescarga', 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 = 'w-100 h-50 mt-3'; 6 contenedor.className = 'w-100 h-50 mt-3';
7 el.append(contenedor); 7 el.append(contenedor);
8 scope.map = L.map(contenedor).setView([-32.89214159952345, -68.84572999101856], attrs.zoom); 8 scope.map = L.map(contenedor).setView([-32.89214159952345, -68.84572999101856], 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', '$timeout', function($scope, $timeout) { 11 controller: ['$scope', '$timeout', function($scope, $timeout) {
12 //resuelve bug mapa gris en modales 12 //resuelve bug mapa gris en modales
13 $timeout(function() { 13 $timeout(function() {
14 $scope.map.invalidateSize(); 14 $scope.map.invalidateSize();
15 }, 1000); 15 }, 1000);
16 16
17 $scope.markers = []; 17 $scope.markers = [];
18 $scope.$watchGroup(['latitud', 'longitud'], function() { 18 $scope.$watchGroup(['latitud', 'longitud'], function() {
19 for(var i in $scope.markers) { 19 for(var i in $scope.markers) {
20 $scope.map.removeLayer($scope.markers[i]); 20 $scope.map.removeLayer($scope.markers[i]);
21 } 21 }
22 $scope.markers.push( 22 $scope.markers.push(
23 L.marker([$scope.latitud, $scope.longitud], {draggable:'true'}) 23 L.marker([$scope.latitud, $scope.longitud], {draggable:'true'})
24 .addTo($scope.map) 24 .addTo($scope.map)
25 .on('dragend', function() { 25 .on('dragend', function() {
26 $scope.latitud = this.getLatLng().lat; 26 $scope.latitud = this.getLatLng().lat;
27 $scope.longitud = this.getLatLng().lng; 27 $scope.longitud = this.getLatLng().lng;
28 $scope.$apply(); 28 $scope.$apply();
29 }) 29 })
30 ); 30 );
31 }); 31 });
32 }], 32 }],
33 scope: { 33 scope: {
34 latitud: '=', 34 latitud: '=',
35 longitud: '=', 35 longitud: '=',
36 zoom: '=' 36 zoom: '='
37 } 37 }
38 }; 38 };
39 }); 39 });
40 40