[Test] adivina municipios + rendermode
by Francisco
HTML
<script src="http://mapea4-sigc.juntadeandalucia.es/js/mapea-5.0.0.ol.min.js"></script>
<link rel="stylesheet" href="http://mapea4-sigc.juntadeandalucia.es/assets/css/mapea-5.0.0.ol.min.css">
<script src="http://mapea4-sigc.juntadeandalucia.es/js/configuration-5.0.0.js"></script>
<div id="mapjs" class="container"></div>
<div id="pruebas" class="container">
<P>Pincha en un municipio para que aparezca su nombre</P>
<button type="button" onclick="resetea()">Comenzar de nuevo</button>
<P>Pincha para diferenciar entre provincias</P>
<button type="button" onclick="categoryStyle()">Por provincias</button>
</div>
CSS
html,
body,
#map {
padding: 0;
margin: 0;
width: 100%;
height: 100%;
}
JavaScript
var mapajs = M.map({
'container': 'mapjs',
"controls": ["layerswitcher", "mouse", "scale",/* "overviewmap",*/ "panzoombar", "scaleline"],
});
let layer = new M.layer.WFS({
url: "http://www.ieca.junta-andalucia.es/geoserver-ieca/topp/wfs?",
name:"topp:mun_2015",
legend: "Municipios - Plantilla Símbolo",
geometry: 'POLYGON',
//extract: true,
//cql: "nom_provincia LIKE 'SEVILLA'"
}, {}, {
renderMode: "image",
//declutter: true
});
mapajs.addLayers([layer]);
//mapajs.addPlugin(new M.plugin.AttributeTable());
//mapajs.addPlugin(new M.plugin.Printer());
let incognita = new M.style.Polygon({
fill: {
color: 'green',
opacity: 0.8
},
stroke: {
color: 'black',
width: 1
},
label: {
text: '?',
color: 'black',
stroke: {
'color': '#E5FFCC',
'width': 3
}
}
});
layer.on(M.evt.LOAD, function() {
layer.setStyle(incognita);
})
// Juego
let hover = new M.style.Polygon({
fill: {
color: 'red',
opacity: 0.5
},
stroke: {
color: 'black',
width: 1
},
label: {
text: '?',
color: 'black',
stroke: {
'color': '#E5FFCC',
'width': 3
}
}
});
let yavistos = new M.style.Polygon({
fill: {
color: 'orange',
opacity: 0.5
},
stroke: {
color: 'black',
width: 1
},
label: {
text: function(feature) {
return (feature.getAttribute('Municipio'))
},
color: 'black',
stroke: {
'color': '#E5FFCC',
'width': 3
}
}
});
let seleccionado = new M.style.Polygon({
fill: {
color: 'yellow',
opacity: 0.5
},
stroke: {
color: 'black',
width: 1
},
label: {
text: function(feature) {
return (feature.getAttribute('Municipio'))
},
color: 'black',
stroke: {
'color': '#E5FFCC',
'width': 3
}
}
});
// Version que oculta los seleccionados anteriores
/*layer.on(M.evt.SELECT_FEATURES,
function(features) {
layer.redraw();
console.log('Seleccionado feature');
let...