Commit 99d02b55e2f3b248bd9c84ed6b8fdcd4e1a77d29

Authored by Pablo Marco del Pont
1 parent b8263cd6d0
Exists in master

Fix de inyección de dependencia.

Showing 1 changed file with 2 additions and 2 deletions   Show diff stats
src/js/osm-directive.js
1 angular.module('focaAdminSeguimiento').directive('osm', function() { 1 angular.module('focaAdminSeguimiento').directive('osm', 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 el.append(contenedor); 6 el.append(contenedor);
7 scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom); 7 scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom);
8 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); 8 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map);
9 }, 9 },
10 controller: function($scope) { 10 controller: ['$scope', function($scope) {
11 $scope.$watch('marcadores', function(valorNuevo) { 11 $scope.$watch('marcadores', function(valorNuevo) {
12 marcadores = $scope.marcadores; 12 marcadores = $scope.marcadores;
13 mapa = $scope.map; 13 mapa = $scope.map;
14 angular.forEach($scope.marcadores, function(marcador) { 14 angular.forEach($scope.marcadores, function(marcador) {
15 L.marker([marcador.latitud, marcador.longitud]).addTo($scope.map) 15 L.marker([marcador.latitud, marcador.longitud]).addTo($scope.map)
16 .bindPopup( 16 .bindPopup(
17 "Actividad: " + marcador.actividad + '<br/>' + 17 "Actividad: " + marcador.actividad + '<br/>' +
18 'Fecha: ' + marcador.fecha 18 'Fecha: ' + marcador.fecha
19 ).openPopup(); 19 ).openPopup();
20 }); 20 });
21 }); 21 });
22 }, 22 }],
23 scope: { 23 scope: {
24 latitud: '=', 24 latitud: '=',
25 longitud: '=', 25 longitud: '=',
26 zoom: '=', 26 zoom: '=',
27 marcadores: '=' 27 marcadores: '='
28 } 28 }
29 }; 29 };
30 }); 30 });
31 31