CP-073-03
Choropleth POL
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="polygons_jenks()">Jenks</button>
<button onclick="polygons_quantile()">Quantile</button>
<button onclick="polygons_quantile2()">QUANTILE (Custom Styles</button>
<button onclick="polygons_jenks2()">JENKS (Custom Styles)</button>
<button onclick="polygons_setStyles()">set styles</button>
<button onclick="polygons_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 </button>
<button onclick="getStyles()">Get Styles</button>
<button onclick="getQuantification()">Get quantification</button>
<button onclick="getValues()">Get values</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 JENKS 3</button>
...
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
// CP-073-03 choropleth_pol
// Prueba orientada a verificar los métodos de coropletas
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 polygons = new M.layer.WFS({
name: "Municipios",
url: "https://clientes.guadaltel.es/desarrollo/geossigc/wfs?",
namespace: "mapea",
name: "da_municipio_pol",
legend: "Municipios - Plantilla Símbolo",
getfeatureinfo: "plain",
geometry: 'POLYGON',
extract: true,
});
mapajs.addLayers(polygons);
let jenks = M.style.quantification.JENKS;
let quantile = M.style.quantification.QUANTILE;
function polygons_jenks() {
let choropleth = new M.style.Choropleth("cod_ine_municipio", null, jenks(numClass()));
polygons.setStyle(choropleth);
}
function polygons_quantile() {
let choropleth = new M.style.Choropleth("cod_ine_municipio", null, quantile(numClass()));
polygons.setStyle(choropleth);
}
function polygons_jenks2() {
let stylesPoint = [
new M.style.Polygon({
fill: {
color: '33BBFF'
}
}),
new M.style.Polygon({
fill: {
color: '#FF0099'
}
}),
new M.style.Polygon({
fill: {
color: '#00AAAA'
}
})
];
let choropleth = new M.style.Choropleth("cod_ine_municipio", stylesPoint, M.style.quantification.JENKS()); //M.style.quantification.JENKS() --> f(d, l = 6) --> f(d, 2)
polygons.setStyle(choropleth);
}
function polygons_quantile2() {
let stylesPoint = [
new M.style.Polygon({
fill: {
...