From a3e5f2152be4534a8f8d28ad6d9b1684c73ea9da Mon Sep 17 00:00:00 2001 From: Jose Pinto Date: Thu, 17 Jan 2019 13:30:56 -0300 Subject: [PATCH] agrego mapa con marcador draggable --- index.html | 38 ++++++++++++++++++++++++++++++++++++ package.json | 1 + src/js/controller.js | 4 +++- src/js/osm-directive.js | 39 +++++++++++++++++++++++++++++++++++++ src/views/modal-punto-descarga.html | 26 ++++++++++++++----------- 5 files changed, 96 insertions(+), 12 deletions(-) create mode 100644 index.html create mode 100644 src/js/osm-directive.js diff --git a/index.html b/index.html new file mode 100644 index 0000000..4e5c9e7 --- /dev/null +++ b/index.html @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + diff --git a/package.json b/package.json index a93c394..b1031ce 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "jquery": "^3.3.1", "jshint": "^2.9.6", "ladda": "^1.0.6", + "leaflet": "^1.3.4", "pre-commit": "^1.2.2", "pump": "^3.0.0", "ui-bootstrap4": "^3.0.5" diff --git a/src/js/controller.js b/src/js/controller.js index 36c455e..f8dccdb 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -17,7 +17,9 @@ angular.module('focaModalPuntoDescarga') $scope.puntoDescarga = { id: 0, id_cliente: filters.idCliente, - id_da_config_0: filters.idDomicilio + id_da_config_0: filters.idDomicilio, + latitud: -32.89214159952345, + longitud: -68.84572999101856 }; $scope.articulos = angular.copy(filters.articulos); $scope.articulos.map(function(articulo) { diff --git a/src/js/osm-directive.js b/src/js/osm-directive.js new file mode 100644 index 0000000..19d2c77 --- /dev/null +++ b/src/js/osm-directive.js @@ -0,0 +1,39 @@ +angular.module('focaLogisticaPedidoRuta').directive('osma', function() { + return { + restrict: 'E', + link: function(scope, el, attrs) { + var contenedor = document.createElement('div'); + contenedor.className = 'w-100 h-50 mt-3'; + el.append(contenedor); + scope.map = L.map(contenedor).setView([-32.89214159952345, -68.84572999101856], attrs.zoom); + L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); + }, + controller: ['$scope', '$timeout', function($scope, $timeout) { + //resuelve bug mapa gris + $timeout(function() { + $scope.map.invalidateSize(); + }, 1000); + + $scope.markers = []; + $scope.$watchGroup(['latitud', 'longitud'], function() { + for(var i in $scope.markers) { + $scope.map.removeLayer($scope.markers[i]); + } + $scope.markers.push( + L.marker([$scope.latitud, $scope.longitud], {draggable:'true'}) + .addTo($scope.map) + .on('dragend', function() { + $scope.latitud = this.getLatLng().lat; + $scope.longitud = this.getLatLng().lng; + $scope.$apply(); + }) + ); + }); + }], + scope: { + latitud: '=', + longitud: '=', + zoom: '=' + } + }; +}); diff --git a/src/views/modal-punto-descarga.html b/src/views/modal-punto-descarga.html index 8b17333..ae13bc5 100644 --- a/src/views/modal-punto-descarga.html +++ b/src/views/modal-punto-descarga.html @@ -67,6 +67,16 @@
+
+ + +
+
+
-
-
- - -
-
+
-- 1.9.1