Commit f3b8d5407e891c3f830547d95ebe78d233e9bb32
Exists in
master
and in
1 other branch
Merge branch 'master' into 'master'
Master (pmarco) See merge request modulos-npm/foca-admin-seguimiento!1
Showing
1 changed file
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: ['$scope', '$filter', function($scope, $filter) { | 10 | controller: ['$scope', '$filter', function($scope, $filter) { |
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: ' + $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + | 18 | 'Fecha: ' + $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + |
19 | ' ' + marcador.fecha.slice(11,19) | 19 | ' ' + marcador.fecha.slice(11,19) + '<br/>' + |
20 | marcador.observaciones | ||
20 | ).openPopup(); | 21 | ).openPopup(); |
21 | }); | 22 | }); |
22 | }); | 23 | }); |
23 | }], | 24 | }], |
24 | scope: { | 25 | scope: { |
25 | latitud: '=', | 26 | latitud: '=', |
26 | longitud: '=', | 27 | longitud: '=', |
27 | zoom: '=', | 28 | zoom: '=', |
28 | marcadores: '=' | 29 | marcadores: '=' |
29 | } | 30 | } |
30 | }; | 31 | }; |
31 | }); | 32 | }); |
32 | 33 |