Commit dca2ba1af7d9c40f493d9fc6461de08648d51235

Authored by Luigi
1 parent df0e6ba68b
Exists in master and in 1 other branch develop

espacios

Showing 1 changed file with 0 additions and 2 deletions   Show diff stats
src/js/osm-directive.js
1 angular.module('focaModalPuntoDescarga').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); 8 scope.map = L.map(contenedor);
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 }, 100); 15 }, 100);
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.map.setView([$scope.latitud, $scope.longitud], 14); 22 $scope.map.setView([$scope.latitud, $scope.longitud], 14);
23 $scope.markers.push( 23 $scope.markers.push(
24 L.marker([$scope.latitud, $scope.longitud], {draggable: true}) 24 L.marker([$scope.latitud, $scope.longitud], {draggable: true})
25 .addTo($scope.map) 25 .addTo($scope.map)
26 .on('dragend', function() { 26 .on('dragend', function() {
27 $scope.latitud = this.getLatLng().lat; 27 $scope.latitud = this.getLatLng().lat;
28 $scope.longitud = this.getLatLng().lng; 28 $scope.longitud = this.getLatLng().lng;
29 $scope.$apply(); 29 $scope.$apply();
30 }) 30 })
31 ); 31 );
32
33 }); 32 });
34 }], 33 }],
35
36 scope: { 34 scope: {
37 latitud: '=', 35 latitud: '=',
38 longitud: '=', 36 longitud: '=',
39 zoom: '=' 37 zoom: '='
40 } 38 }
41 }; 39 };
42 }); 40 });
43 41