CP-073-02

Choropleth LIN

by SIGC

HTML

<script src="https://sigc.desarrollo.guadaltel.es/mapea5/js/mapea.ol.min.js"></script>
<link rel="stylesheet" href="https://sigc.desarrollo.guadaltel.es/mapea5/assets/css/mapea.ol.min.css">
<script src="https://sigc.desarrollo.guadaltel.es/mapea5/js/configuration.js"></script>
  <table id="tableStyle">
      <tr>
        <th onclick="ocultarTable('setters')">Setters</th>
      </tr>
      <tr>
        <td id="setters-td" class="display-hidden">
          <button onclick="lines_jenks()">Jenks</button>
          <button onclick="lines_quantile()">Quantile</button>
          <button onclick="lines_quantile2()">QUANTILE (Custom Styles</button>
          <button onclick="lines_jenks2()">JENKS (Custom Styles)</button>
          <button onclick="lines_setStyles()">set styles</button>
          <button onclick="lines_setQuantification()">set quantification</button>
        </td>
      </tr>
      <tr>
        <th onclick="ocultarTable('getters')">Getters</th>
      </tr>
      <tr>
        <td id="getters-td" class="display-hidden">
          <button onclick="getAttributeName()">Get attribute name (Puntos)</button>
          <button onclick="getStyles()">Get Styles (Poligonos)</button>
          <button onclick="getQuantification()">Get quantification (Lineas)</button>
          <button onclick="getValues()">Get values (Poligonos)</button>
        </td>
      </tr>
      <tr>
        <th onclick="ocultarTable('constructor')">Constructores</th>
      </tr>
      <tr>
        <td id="constructor-td" class="display-hidden">
          <button onclick="option1()">Atributo + estilos null + cuantificador null</button>
          <button onclick="option2()">Atributo + estilos null + cuantificador JENKS 3</button>
          <button onclick="option3()">Atributo + array estilos + cuantificador null</button><br>
          <button onclick="option4()">Atributo + array estilos + cuantificador JENKS 3</button>
          <button onclick="option5()">Atributo + estilos null + cuantificador...

CSS

html,
      body {
        margin: 0;
        padding: 0;
        height: 100%;
        overflow: auto;
      }

      #tableStyle {
        font-family: arial, sans-serif;
        border-collapse: collapse;
        width: 100%;
      }

      table#tableStyle td {
        border: 1px solid #dddddd;
        text-align: left;
        padding: 8px;
      }

      table#tableStyle th {
        border: 1px solid #dddddd;
        text-align: left;
        padding: 8px;
      }

      table#tableStyle tr:nth-child(even) {
        background-color: #dddddd;
      }

      input-group {
        margin: 20%;
      }

      .display-hidden {
        display: none;
      }

JavaScript

let mapajs = M.map({
  container: "map",
  projection: "EPSG:4326*m",
  layers: ["OSM"],
  center: [
    -6.39404296875,
    36.99377838872517
  ],
  zoom: 5,
  controls: ['layerswitcher', 'overviewmap'],
});

mapajs.addPlugin(new M.plugin.Printer({
  "params": {
    "pages": {
      "clientLogo": "http://www.juntadeandalucia.es/economiayhacienda/images/plantilla/logo_cabecera.gif",
      "creditos": "Impresión generada a través de Mapea"
    },
    "layout": {
      "outputFilename": "mapea_${yyyy-MM-dd_hhmmss}"
    }
  }
}, {
  "options": {
    "legend": "true"
  }
}));

let lines = new M.layer.WFS({
  name: "Ríos",
  url: "https://clientes.guadaltel.es/desarrollo/geossigc/wfs",
  namespace: "mapea",
  name: "mapb_hs1_100",
  legend: "mapb_hs1_100 - COROPLETAS",
  getfeatureinfo: "plain",
  geometry: 'LINE',
  extract: true
});


mapajs.addLayers(lines);
let jenks = M.style.quantification.JENKS;
let quantile = M.style.quantification.QUANTILE;

function lines_jenks() {
  let choropleth = new M.style.Choropleth("cod_rio", null, jenks(numClass()));
  lines.setStyle(choropleth);
}

function lines_quantile() {
  let choropleth = new M.style.Choropleth("cod_rio", null, quantile(numClass()));
  lines.setStyle(choropleth);
}

function lines_jenks2() {
  let stylesPoint = [
      new M.style.Line({
      fill: {
        color: '33BBFF'
      }
    }),
    new M.style.Line({
      fill: {
        color: '#FF0099'
      }
    }),
    new M.style.Line({
      fill: {
        color: '#00AAAA'
      }
    })
  ];
  let choropleth = new M.style.Choropleth("cod_rio", stylesPoint, M.style.quantification.JENKS()); //M.style.quantification.JENKS() --> f(d, l = 6) --> f(d, 2)
  lines.setStyle(choropleth);
}

function lines_quantile2() {
  let stylesPoint = [
      new M.style.Line({
      fill: {
        color: '33BBFF'
      }
    }),
    new M.style.Line({
      fill: {
        color: '#FF0099'
      }
    }),
    new M.style.Line({
      fill: {
        color: '#00AAAA'
     ...