mapa_main.js 24.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519
/*** Global object that contains the app ***/
var app = app || {};

// keep our map stuff in a part of the app object as to not pollute the global name space
app.map = (function(w,d, $, _){
  var el = {
    map:null,cdbURL:null,styles: null,params:null,
    styleCur:null,sql:null,
    mapboxTiles:null,satellite:null,taxLots:null,
    baseLayers:null,capaMANZ:null,capaCALLES:null,capasinCCC:null,polygon:null,
    bushwick:null,colony : null,linden : null,groveSt : null,featureGroup : null,
    template:null,menu:null,
    legend:null,menud:null, mostrar: null,
    taxLotActions:null,story:null
  };

  //SE CARGAN VALORES REUTILIZABLES
  el.styles = app.mapStyles;  //ESTILOS
  el.params = app.param;      //PARAMETROS
  el.cdbURL = app.url;        //URL MAPA BASE

  // compile the underscore legend template for rendering map legends for choropleth layers
  _.templateSettings.variable = "legend";
  el.template = _.template($("script.template").html());

  el.legendcontainer = $('#ui-leyenda-contenedor');
  el.legend = $('#ui-legend');
  el.menu = $('#accordion');

  // Configuramos el mapa y sus capas!
  var initMap = function() {
    // Ocultamos datos, resumen y tooltip
    $('#box2').hide();$('#tool-tip').hide();

    // Parametros del mapa de FONDO
    var params = {center:[lat,lng],minZoom:minzoom,maxZoom:maxzoom,zoom:zoom,maxBounds:L.latLngBounds(corner1,corner2),zoomControl:false,infoControl:false,attributionControl:true}
    el.map = new L.map('map', params);



    // tileLayer for mapbox basemap
    el.mapboxTiles = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
            maxZoom: 19,
            attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
        });
    el.map.addLayer(el.mapboxTiles);

    //TODO: Capa Nokia  layer.tileLayer('http://{s}.maps.nlp.nokia.com/maptile/2.1/maptile/newest/satellite.day/{z}/{x}/{y}/256/jpg?lg=eng&token=A7tBPacePg9Mj_zghvKt9Q&app_id=KuYppsdXZznpffJsKT24', {
    //      subdomains:"1234", attribution: '&copy; <a href="http://maps.nokia.com/copyright">Nokia Maps</a> contributors, &copy; <a href="http://yvyape.yvaga.com/attributions">YVAGA</a>'}).addTo(map);
    // add mapbox and osm attribution
    var attr = "<a href='https://www.mapbox.com/about/maps/' target='_blank'>&copy; Mapbox &copy; OpenStreetMap</a>"
    el.map.attributionControl.addAttribution(attr);

    // add Bing satelitte imagery layer
    el.satellite = new L.BingLayer('AkuX5_O7AVBpUN7ujcWGCf4uovayfogcNVYhWKjbz2Foggzu8cYBxk6e7wfQyBQW');

    // Capas bases para leaflet
     el.baseLayers = {geometrico: el.mapboxTiles,foto: el.satellite};

    // inits UI element for toggling base tile layers
    L.control.layers(el.baseLayers, {}, {position: 'bottomleft'}).addTo(el.map);

    // makes sure base layers stay below the cartodb data
    el.map.on('baselayerchange', function(e){e.layer.bringToBack();})

    // se agregan las capas
    $(document).ajaxStart(function() { Pace.restart(); });
    getCDBData();
      $('#box').show();
  }

  // Carga capa Base y ADICIONALES

  var getCDBData = function() {
    cartodb.createLayer(el.map, el.cdbURL, {cartodb_logo: false,legends: false,https: true},
      function(layer) {

          //TODO: VERIFICAR QUE ESTE 'LOADER' FUNKE
          var loader = new cdb.geo.ui.TilesLoader({ template: function(){ return '<div class="loader"></div>' } });

          function addLoader(layer) {
              layer.bind('loading', function() { loader.show() });
              layer.bind('load',  function() { loader.hide(); });
          }

          // se almacenan las capas en las variables correspondientes
          layer.getSubLayer(0).setCartoCSS(el.styles.regular);
          layer.getSubLayer(0).setSQL(el.params.morosidadtodos);
          el.taxLots = layer.getSubLayer(0);

          //CAPAS ADICIONALES
          el.capaMANZ   = layer.createSubLayer({sql : el.params.manzanas, cartocss : el.styles.manzanas});
          el.capaCALLES = layer.createSubLayer({sql : el.params.calles,   cartocss : el.styles.calles});
          el.capasinCCC = layer.createSubLayer({sql : el.params.lotesincc,cartocss : el.styles.lotesincc});

          // Mueve la posición del tool-tip respecto a la ubicación del mouse 5px, para no interferir en el proceso de "click"
          var event = function (e) {$('#tool-tip').css({left: e.pageX + 5,top: e.pageY + 5});};

          // hide and set interactivity on the DOB permit layers
          var num_sublayers = layer.getSubLayerCount();
          // Se esconden todas las capas cargadas
          for (var i = 1; i < num_sublayers; i++) {layer.getSubLayer(i).hide();}
          //console.log(num_sublayers);

          // Se activa la interactividad y se especifica los campos activados para dicho fin
          layer.getSubLayer(0).setInteraction(true);
          layer.getSubLayer(0).setInteractivity('cartodb_id, ultimo_pago, trb_total_deuda, ccc, cc_man, cc_lote, layer, obs, inm_ficha');

          //Feature on Mouse CLICK
          layer.on('featureClick', function(e, pos, latlng, data) {
              if (typeof impuesto !== "undefined") {
                  showFeature(data.cartodb_id, data.ccc);
              }else{showFeature(data.cartodb_id, data.ccc);}
          });

          //Feature Mouse OVER
          layer.getSubLayer(0).on('featureOver', function(e, pos, latlng, data) {
              ultimo_pago = data.ultimo_pago;
              cuenta = data.ccc;
              if (data.ultimo_pago == null){ultimo_pago = "N/A";}else{ultimo_pago = data.ultimo_pago;}
              if (data.inm_ficha == null){ficha = "SIN FICHA";}else{ficha = data.inm_ficha;}
              if (data.obs == null){observaciones = "SIN OBSERVACIONES";}else{observaciones = data.obs;}
              $('#map').css('cursor', 'pointer');
              $('#tool-tip').show().html(
                    // Contenido del Tool-Tip
                    '<h4>Informacion Adicional</h4>' +
                    '<hr>' +
                    '<p><strong> FICHA:</strong> ' + ficha + '</p>' +
                    '<p><strong>Manzana:</strong> '  + data.cc_man + '</p>' +
                    '<p><strong>Numero de Lote:</strong> ' + data.cc_lote + '</p>' +
                    '<p><strong>OBS.:</strong> '  + observaciones + '</p>'
              );
              $(document).bind('mousemove', event);
              document.getElementById("ultimo").innerHTML = ultimo_pago;
              document.getElementById("ccc").innerHTML = cuenta;
          });
          //Feature Mouse OUT
          layer.getSubLayer(0).on('featureOut', function(e,pos,latlng,data){
              $('#tool-tip').hide();
              $(document).unbind('mousemove', event, false);
          });

          el.map.addLayer(layer, false);
          // make sure the base layer stays below the cdb layer
          el.mapboxTiles.bringToBack();
      }).on('done', function() {
    }); // end cartodb.createLayer!

  };

  var showFeature = function (cartodb_id, ccc) {
    $('#box2').show();
    $('#tool-tip').hide();
    $.ajax({
      url: "api/callREAD.php",
      type: "POST",
      data: {cartodb_id: cartodb_id, type: 'lote', entidad: entidad},
      dataType: 'json',
      success: function (geojson) {
          if (el.polygon) {el.map.removeLayer(el.polygon);}
          el.polygon = L.geoJson(geojson, {
              style: {
                  color: "#000",
                  fillColor: "#edd711",
                    weight: 6,
                  opacity: 0.8,
                  fillOpacity: 0.2
              }
          });
          el.map.fitBounds(el.polygon.getBounds(), {maxZoom: 17});
          el.polygon.addTo(el.map);
          //console.log(polygon.getBounds()); //DEFINICION DEL POLIGONO
          if (typeof impuesto !== "undefined") {
            //console.log(entidad, impuesto, estado);
              $.ajax
              ({
                  url: 'login/get_liquidacion.php', //Se parsea el numero de ccc a fin de obtener los datos del lote
                  type: 'POST',
                  data: {ccc: ccc, entidad: entidad, impuesto: impuesto, estado: estado},//parseo de ccc
                  dataType: "json", //text or html or json or script
                  success:function(data)
                  {
                      var largo = data.length;
                      //SE LIMPIA EL DIV DE RESULTADOS
                      $("#toggle_resumen").html("").append('<a href="#" id="toggle_all" style="tex-alignment: left; padding-right: 3em" onclick="limpiar()">Mostrar Todos</a>');
                      $("#box").css({'opacity':'0.8'});
                      //TODO: aca podria haber sido overlowY en el "scroll" para contemplar solo el scroll vertical, preferi dejar ambos para que se "note que hay algo"
                      //console.log(largo);

                      if (largo > 0){
                          // SE CREA EL INFORME POR LOTE
                          $("#resumen").html("").css({display: 'block', height: '90%', overflow: 'scroll'}
                          ).append('' +
                              '<p style="text-align: center;color:black;font-size: 20px">Informe Catastral</p>' +
                              '<p style="color:black"><b>Lote: </b>'+ccc+' <b>Ficha:</b> '+data[0].inm_ficha+'</p>'+
                              //SE CREA LA TABLA PARA EL RESUMEN
                              '<table id="resumen_table" class="table">'+
                              '<tr>'+
                                  '<th>Ejercicio Fiscal</th>'+
                                  '<th>Tributo</th>'+
                                  '<th>Estado</th>'+
                                  '<th>Importe</th>'+
                                  '<th>Fecha de pago</th>'+
                              '</tr>');
                          //SE IMPRIMEN LOS DATOS DEL LOTE
                          var sum = 0;
                          $.each(data,function (i,item) {
                              switch (item.liq_estado){
                                  case 'REG':
                                      estadopago = 'PENDIENTE';
                                      tiporesumen = 'ADEUDADO';
                                      break;
                                  case 'PAG':
                                      tiporesumen = 'PAGADO';
                                      estadopago = item.liq_fecpago;
                                      break;
                              }
                              sum += parseInt(item.liq_importe_apagar);

                              $('#resumen_table').append(
                                  '<tr>' +
                                      '<td>'+item.ejer_fisca+'</td>' +
                                      '<td>'+item.trb_tributo+'</td>' +
                                      '<td>'+item.liq_estado+'</td>' +
                                      '<td>'+$.number(item.liq_importe_apagar,0,',','.')+'</td>' +
                                      '<td>'+estadopago+'</td>' +
                                  '</tr>'
                              );
                              //console.log(sum, item);
                          });
                          $('#resumen').append(
                              '</table><p style="text-align: left; font-size: 20px; color:black;">Total '+tiporesumen+': <b>'+ $.number(sum,0,',','.')+' Gs.</b></p>');
                          $('#toggle_resumen').append('<a href="#" id="toggle_msg" style="text-align: center; padding-right: 3em;" onclick="mostrarResumen()">Ocultar Resumen</a>'+
                              '<input type="button" style="color: black" id="print_resumen" value="Imprimir Resumen" onclick="printDiv();">'
                          );
                      }else{
                          $("#box2").css({display: 'block', height: 'auto'});
                          $("#resumen").html("").css({display: 'block', height: 'auto', overflow: ''}).append('<p style="text-align: center">No se encontraron Datos<p>');
                      }
                  },
                  error:function(data){
                      $('#resumen').html("").append('<p style="text-align: center; font-size: 10px; color:black;">No se encontraron datos</p>')
                  }
              });;
          }else {
              //alert("FAVOR ELIJA TIPO DE IMPUESTO!");
          }
      }
    });
  };

  // change the cartoCSS of a layer
  var changeCartoCSS = function(layer, css) {layer.setCartoCSS(css);};

  // change SQL query of a layer
  var changeSQL = function(layer, sql) {layer.setSQL(sql);};

    // corresponding cartoCSS & SQL changes to tax lot layer buttons
  // legends are displayed or hidden as needed
  el.taxLotActions = {
    regular : function() {
      changeCartoCSS(el.taxLots, el.styles.regular);
      changeSQL(el.taxLots, el.params.morosidadtodos);
      renderLegend(null);
      return true;
    },
    totales : function() {
        //TODO: MEJORAR LOGICA!!
        switch (estado){
            case 'REG':
                colormaximo = '#BD0026';
                color80 = '#F03B20';
                color60 = '#FFCC00';
                color40 = '#95ad42';
                color20 = '#2a722f';
                colorminimo = '#8e8e8e';
                titulo = 'ADEUDADO';
                label_leyenda = 'NO REGISTRADOS/NO LIQUIDADOS';
            break;
            case 'PAG':
                colormaximo = '#2a722f';
                color80 = '#95ad42';
                color60 = '#FFCC00';
                color40 = '#F03B20';
                color20 = '#BD0026';
                colorminimo= '#8e8e8e';
                titulo = 'PAGADO';
                label_leyenda = 'NO REGISTRADOS/NO PAGADOS';
            break;
        }

        if (porciento80 === minimo) {
            lotetotales = '#e'+entidad+'_lotes_conccc{polygon-fill: #FFFFB2;polygon-opacity: 0.8;line-color: #FFF;line-width: 0.5;line-opacity: 1;}'+
                '#e'+entidad+'_lotes_conccc [ '+tipodeuda+' > ' +porciento80+ ' ] {polygon-fill: '+colormaximo+';}' +
                '#e'+entidad+'_lotes_conccc [ '+tipodeuda+' = ' +porciento80+ '] {polygon-fill: '+color80+';}' +
                '#e'+entidad+'_lotes_conccc [ '+tipodeuda+' < ' +minimo+ '] {polygon-fill: '+colorminimo+';}'+
                '#e'+entidad+'_lotes_conccc [ '+tipodeuda+' = null] {polygon-fill: '+colorminimo+';}'
            ;
        }
        else {
            lotetotales = '' +
                '#e'+entidad+'_lotes_conccc{polygon-fill: #FFFFB2;polygon-opacity: 0.8;line-color: #FFF;line-width: 0.5;line-opacity: 1;}'+
                '#e'+entidad+'_lotes_conccc [ '+tipodeuda+' > ' +porciento80+ ' ] {polygon-fill: '+colormaximo+';}' +
                '#e'+entidad+'_lotes_conccc [ '+tipodeuda+' <= ' +porciento80+ '] {polygon-fill: '+color80+';}' +
                '#e'+entidad+'_lotes_conccc [ '+tipodeuda+' <= ' +porciento60+ '] {polygon-fill: '+color60+';}' +
                '#e'+entidad+'_lotes_conccc [ '+tipodeuda+' <= ' +porciento40+'] {polygon-fill: '+color40+';}' +
                '#e'+entidad+'_lotes_conccc [ '+tipodeuda+' <= ' +porciento20+ '] {polygon-fill: '+color20+';}' +
                '#e'+entidad+'_lotes_conccc [ '+tipodeuda+' < ' +minimo+ '] {polygon-fill: '+colorminimo+';}'+
                '#e'+entidad+'_lotes_conccc [ '+tipodeuda+' = null] {polygon-fill: '+colorminimo+';}'
            ;
        }
        changeCartoCSS(el.taxLots, lotetotales);
        //el.params.morosidadtodos+ " where (trb_tributo ilike '"+impuesto+"' and "+tipodeuda+" > 0) or trb_tributo is null";
        sqltotales = el.params.morosidadtodos + " where (trb_tributo ilike '"+impuesto+"' or trb_tributo is null) ";

        if (sqlnuevo === "") {
            changeSQL(el.taxLots, sqltotales);
        }else{
            filtro = parseInt(array.rows[idactual][filtroactual]);
            //console.log (typeof filtro);
            sqlnuevo = sqlnuevo + " and "+tipodeuda+" " + op + " " + eval(filtro);
            //console.log(sqlnuevo);
            changeSQL(el.taxLots, sqlnuevo);
            changeCartoCSS(el.taxLots, lotetotales);
            sqlnuevo = "";
            filtro = "";
        }
        //TODO: MEJORAR LOGICA DE RENDER LEGENDA!
        if (porciento80 === minimo){
            renderLegend(
                {title : "Total "+ titulo,
                    items : [
                        {color : colormaximo, label : "> " +$.number(porciento80,0,',','.')+" Gs", filtroid : "porciento80", op : " > " },
                        {color : color80, label : "= "+$.number(porciento80,0,',','.')+" Gs", filtroid : "porciento80", op : " = "  },
                        {color : "hsl(48, 100%, 50%)", label : label_leyenda, filtroid : "minimo", op : " < " }
                    ]
                }
            );
        }
        else{
          renderLegend(
              {title : "Total "+ titulo,
                  items : [
                      {color : colormaximo, label : "> " +$.number(porciento80,0,',','.')+" Gs", filtroid : "porciento80", op : " > " },
                      {color : color80, label : "<= "+$.number(porciento80,0,',','.')+" Gs", filtroid : "porciento80", op: " <= " },
                      {color : color60, label : "<= "+$.number(porciento60,0,',','.')+" Gs", filtroid : "porciento60", op: " <= "},
                      {color : color40, label : "<= "+$.number(porciento40,0,',','.')+" Gs", filtroid : "porciento40", op: " <= " },
                      {color : color20, label : "<= "+$.number(porciento20,0,',','.')+" Gs", filtroid : "porciento20", op: " <= " },
                      {color : "#787878", label : label_leyenda, filtroid : "minimo", op: "<"}
                  ]
              }
          );
        }
      $('#tool-tip').show();
      $('#box').show();
      //TODO: seguir //getCDBData().getSubLayer(0).hide();
      return true;
    },
    ultimopagado : function(){
        switch (estado){
            case 'REG': //TODO: REVISAR LOGICA
                colormaximo = '#2a722f';
                color80 = '#95ad42';
                color60 = '#FFCC00';
                color40 = '#F03B20';
                color20 = '#BD0026';
                colorminimo= '#8e8e8e';
                titulo = 'ADEUDADO';
            break;
            case 'PAG':
                colormaximo = '#2a722f';
                color80 = '#95ad42';
                color60 = '#FFCC00';
                color40 = '#F03B20';
                color20 = '#BD0026';
                colorminimo= '#8e8e8e';
                titulo = 'PAGADO';
            break;
        }
        //TODO: Dinamico
        lotesultimopagado = '#e'+entidad+'_lotes_conccc{polygon-fill: #006D2C;polygon-opacity: 0.8;line-color: #FFF;line-width: 0.5;line-opacity: 1;}'+
            '#e'+entidad+'_lotes_conccc [ ultimo_pago = '+periodo+'] {polygon-fill: '+colormaximo+';}'+
            '#e'+entidad+'_lotes_conccc [ ultimo_pago <= '+periodo1+'] {polygon-fill: '+color80+';}'+
            '#e'+entidad+'_lotes_conccc [ ultimo_pago <= '+periodo2+'] {polygon-fill: '+color60+';}'+
            '#e'+entidad+'_lotes_conccc [ ultimo_pago <= '+periodo3+'] {polygon-fill: '+color40+';}'+
            '#e'+entidad+'_lotes_conccc [ ultimo_pago <= '+periodo4+'] {polygon-fill: '+color20+';}'+
            '#e'+entidad+'_lotes_conccc [ ultimo_pago <= '+periodo5+'] {polygon-fill: '+color20+';}'+
            '#e'+entidad+'_lotes_conccc [ ultimo_pago  = null] {polygon-fill: '+colorminimo+';}';
      changeCartoCSS(el.taxLots, lotesultimopagado);
        sqlultimopagado = el.params.morosidadtodos+ " where (trb_tributo ilike '"+impuesto+"' and "+tipodeuda+" > 0) or trb_tributo is null";
        //console.log(sqlultimopagado);
          if (sqlnuevo === ""){changeSQL(el.taxLots, sqlultimopagado);}
          else {
              sqlnuevo = sqlnuevo + "and ultimo_pago " +op+ " " + eval(filtroactual);
              //console.log(sqlnuevo);
              changeSQL(el.taxLots, sqlnuevo);
              changeCartoCSS(el.taxLots, lotesultimopagado);
              sqlnuevo = "";
              filtro = "";
          }
      //TODO: Debe ser dinamico
      renderLegend({
          title : "Ultimo "+ titulo,
          items : [
              {color : colormaximo, label : "= " + periodo, filtroid : periodo, op : " = " }, // igual a ultimo anho
              {color : color80, label : " <= " + periodo1, filtroid : periodo1, op : " <= " },
              {color : color60, label : "<= "+ periodo2, filtroid : periodo2, op : " <= " },
              {color : color40, label : "<= "+ periodo3, filtroid : periodo3, op : " <= " },
              {color : color20, label : "<= "+ periodo4, filtroid : periodo4, op : " <= " },
              {color : color20, label : "<= "+ periodo5, filtroid : periodo5, op : " <= " },
              {color : colorminimo, label : "SIN DEUDA O DEUDAS PRESCRIPTAS", filtroid : periodo6, op : "=<" }
          ]
      });
      return true;
    }
  };

  // add tax lot layer button event listeners
    var initButtons = function() {
        $('.button').click(function(e) {
            //e.preventDefault();
            $(document).ajaxStart(function() { Pace.restart(); });
            limpiar();
            $('.button').removeClass('active');
            $(this).addClass('active');
            idactual = $(this).attr('name');
            impuesto = array.rows[idactual].trb_tributo;
            estado = array.rows[idactual].estado;
            switch (estado) {
                case 'REG':tipodeuda = "trb_total_deuda";break;
                case 'PAG':tipodeuda = "trb_total_pago";break;
            }
            maximo = parseInt(array.rows[idactual].maximo);
            minimo = parseInt(array.rows[idactual].minimo);
            porciento20 = parseInt(array.rows[idactual].porciento20);
            porciento40 = parseInt(array.rows[idactual].porciento40);
            porciento60 = parseInt(array.rows[idactual].porciento60);
            porciento80 = parseInt(array.rows[idactual].porciento80);
            tipofiltro = $(this).attr('id');
            app.map.el.taxLotActions[tipofiltro]();
            var sqlnuevo = "";
            //console.log(tipofiltro);
            //console.log(idactual, impuesto, estado, maximo, minimo, porciento20, porciento40, porciento60, porciento80);
            //console.log(tipodeuda);
            //app.map.el.taxLots.show();
        });
    }

    //SUBFILTRO ONCLICK EN LA LEYENDA
    var initsubfiltro = function(e) {
        $(".subfiltro").click(function() {
            //TODO: AL ELGIR UN FILTRO, PONER EN GRIS LOS DEMAS
            //limpiarfiltros();
            $(this).addClass("selected");
            filtroactual = $(this).attr(toString("filtroid"));
            op = $(this).attr("op");
            //console.log(filtroactual, op);
            //TODO: HASTA LLEGUE POR HOY 11/12/2017 12:26
            sqlnuevo = el.params.morosidadtodos + " where trb_tributo ilike '"+impuesto+"'";

            app.map.el.taxLotActions[tipofiltro]();

        });
    }


  // Muestra las capas adicionales a medida que son marcados los checkboxes
  var initCheckboxes = function() {
    var checkboxDOB = $('input.dob:checkbox'), $manz = $('#manz'), $calle = $('#calle'), $sinccc = $('#sinccc');
    $manz.change(function()  {if ($manz.is(':checked'))  {el.capaMANZ.show()}  else {el.capaMANZ.hide()}});
    $calle.change(function() {if ($calle.is(':checked')) {el.capaCALLES.show()}else {el.capaCALLES.hide()}});
    $sinccc.change(function(){if ($sinccc.is(':checked')){el.capasinCCC.show()}else {el.capasinCCC.hide()}});
  }

  // function to render choropleth legends
  var renderLegend = function(data) {
    if (data === null) {
      //el.legend.addClass('hidden');
      el.legend.removeClass('hidden');
      return;
    }
    var legendData = {title : data.title,items : data.items,};
    el.legend.html(el.template(legendData));
    if (el.legend.hasClass('hidden')) el.legend.removeClass('hidden');
    initsubfiltro();
  }

  // Botones de Zoom Custom
  var initZoomButtons = function(){
    $('#zoom-in').on('click', function(){el.map.zoomIn();});
    $('#zoom-out').on('click', function(){el.map.zoomOut();});
  }



  // get it all going!
  var init = function() {
    //searchAddress();
    initZoomButtons();
    $(document).ajaxStart(function() { Pace.restart(); }); //EFECTO "CARGANDO..."
    initCheckboxes();
    initButtons();
    $(document).ajaxStart(function() { Pace.restart(); }); //EFECTO "CARGANDO..."
    initMap();
  }

  // only return init() and the stuff in the el object
  return {
    init : init,
    el : el
  }

})(window, document, jQuery, _);

// call app.map.init() once the DOM is loaded
window.addEventListener('DOMContentLoaded', function(){
    app.conf.init();
    app.map.init();
});
GitLab Appliance - Powered by TurnKey Linux