Commit bbad86949d1b445aeafa9f7dd402dadc745ea5a2
1 parent
cb2a3a0727
Exists in
master
fix no show map
Showing
1 changed file
with
0 additions
and
1 deletions
Show diff stats
src/js/osm-directive.js
| 1 | angular.module('focaModalLocalizar').directive('osmDireccion', function() { | 1 | angular.module('focaModalLocalizar').directive('osmDireccion', 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'; | ||
| 7 | el.append(contenedor); | 6 | el.append(contenedor); |
| 8 | scope.map = L.map(contenedor).setView([-32.89214159952345, -68.84572999101856], attrs.zoom); | 7 | 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); | 8 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); |
| 10 | }, | 9 | }, |
| 11 | controller: ['$scope', '$timeout', function($scope, $timeout) { | 10 | controller: ['$scope', '$timeout', function($scope, $timeout) { |
| 12 | //resuelve bug mapa gris en modales | 11 | //resuelve bug mapa gris en modales |
| 13 | $timeout(function() { | 12 | $timeout(function() { |
| 14 | $scope.map.invalidateSize(); | 13 | $scope.map.invalidateSize(); |
| 15 | }, 100); | 14 | }, 100); |
| 16 | 15 | ||
| 17 | $scope.markers = []; | 16 | $scope.markers = []; |
| 18 | $scope.$watchGroup(['latitud', 'longitud'], function() { | 17 | $scope.$watchGroup(['latitud', 'longitud'], function() { |
| 19 | for(var i in $scope.markers) { | 18 | for(var i in $scope.markers) { |
| 20 | $scope.map.removeLayer($scope.markers[i]); | 19 | $scope.map.removeLayer($scope.markers[i]); |
| 21 | } | 20 | } |
| 22 | $scope.markers.push( | 21 | $scope.markers.push( |
| 23 | L.marker([$scope.latitud, $scope.longitud], {draggable: true}) | 22 | L.marker([$scope.latitud, $scope.longitud], {draggable: true}) |
| 24 | .addTo($scope.map) | 23 | .addTo($scope.map) |
| 25 | .on('dragend', function() { | 24 | .on('dragend', function() { |
| 26 | $scope.latitud = this.getLatLng().lat; | 25 | $scope.latitud = this.getLatLng().lat; |
| 27 | $scope.longitud = this.getLatLng().lng; | 26 | $scope.longitud = this.getLatLng().lng; |
| 28 | $scope.$apply(); | 27 | $scope.$apply(); |
| 29 | }) | 28 | }) |
| 30 | ); | 29 | ); |
| 31 | }); | 30 | }); |
| 32 | 31 | ||
| 33 | $scope.$on('moveMap', function(evt, data) { | 32 | $scope.$on('moveMap', function(evt, data) { |
| 34 | $scope.map.panTo(new L.LatLng(data.latitud, data.longitud)); | 33 | $scope.map.panTo(new L.LatLng(data.latitud, data.longitud)); |
| 35 | }); | 34 | }); |
| 36 | }], | 35 | }], |
| 37 | scope: { | 36 | scope: { |
| 38 | latitud: '=', | 37 | latitud: '=', |
| 39 | longitud: '=', | 38 | longitud: '=', |
| 40 | zoom: '=' | 39 | zoom: '=' |
| 41 | } | 40 | } |
| 42 | }; | 41 | }; |
| 43 | }); | 42 | }); |
| 44 | 43 |