// Caso de pruebas
// 1.- Carga de capa WFS - Líneas - Ríos - estilo por defecto azul
// 2. Incorpora atributo color con valores "red"
// 3.- Botón Aplicar estilo muestra los estilos por atributo "color". Deben aparecer los features en rojo.
// El canvas de la capa no muestra leyenda porque no se dispone de estilo de color-.
var mapajs = M.map({
'container': 'map',
"controls": ["layerswitcher", "mouse", "scale", "overviewmap", "panzoombar", "scaleline",],
"getfeatureinfo": "plain"
});
// Asigna estilo en el constructor
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",
getfeatureinfo:"plain",
geometry: 'LINE',
extract: true,
},
{
style: new M.style.Line({
stroke: {
color: 'blue',
with: 2
}
})
}
);
// Asigna estilo antes de cargar
lines.setStyle(
new M.style.Line({
stroke: {
color: 'blue',
with: 2
}
}));
lines.on(M.evt.LOAD, function() {
lines.getFeatures().forEach(function(line){
line.setAttribute('color', 'red')
})
});
let plantillaStyle = new M.style.Line({
stroke: {
color: '{{color}}',
}
});
mapajs.addLayers(lines);
mapajs.addPlugin(new M.plugin.AttributeTable());
function setCategoriaStyle(){
if (lines == null ) return;
lines.setStyle(plantillaStyle);
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.