Ver Mensaje Individual
  #4 (permalink)  
Antiguo 07/01/2015, 21:46
Montes28
 
Fecha de Ingreso: septiembre-2010
Mensajes: 1.853
Antigüedad: 13 años, 7 meses
Puntos: 6
Respuesta: Como enviar por ajax grupo de checkbox marcado o sin marcar

lo solucione de una manera pero no me parece la mejor manera, obtengo la longitud del array y cargo nuevamente el mapa

Código Javascript:
Ver original
  1. $(function(){
  2. $('input[type="checkbox"]').change(function(){
  3.  var checkboxValues = new Array();
  4.     $('input[name="estaciones[]"]:checked').each(function() {
  5.           var id=$(this).attr('id');
  6.    
  7.           var value=$(this).val();
  8.           if ($(this).prop('checked')){
  9.               checkboxValues.push($(this).val());
  10.           }
  11.         });
  12.  
  13.          var n = $('input[name="estaciones[]"]:checked').length;
  14.          if (n == 0) {
  15.           var mapOptions = {
  16.           zoom: 10,
  17.           mapTypeId:google.maps.MapTypeId.TERRAIN,
  18.          center: new google.maps.LatLng(4.725620698589212, -75.38406372070312)
  19.   };
  20.   map = new google.maps.Map(document.getElementById('map-canvas'),
  21.       mapOptions);
  22.  
  23.  
  24.          } else{
  25.          var mapOptions = {
  26.           zoom: 10,
  27.           mapTypeId:google.maps.MapTypeId.TERRAIN,
  28.     center: new google.maps.LatLng(4.725620698589212, -75.38406372070312)
  29.   };
  30.   map = new google.maps.Map(document.getElementById('map-canvas'),
  31.       mapOptions);
  32.          };
  33.  
  34.          $.ajax({
  35.           type: "GET",
  36.           url: "getEstaciones",
  37.           data: {info: checkboxValues },
  38.           success: function (result) {
  39.           var estaciones = result;
  40.            //Aqui coloco el marcado en el mapa de google maps
  41.           }
  42.     });
  43. });