// CP-070-02 - Style Line (A nivel de capa y features)
// Caso de prueba orientado a verificar la aplicación de estilos a nivel de capa y a nivel de features.
// PathText a nivel de feature no es compatible
let mapajs = M.map({
container: "map",
projection: "EPSG:4326*d",
layers: ["OSM"],
center: {
x: -5.9584180843195425,
y: 37.36912689160224
},
zoom: 5,
controls: ['layerswitcher', 'overviewmap'],
});
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,
});
mapajs.addLayers([lines]);
let line = null;
//Seleccionamos una linea que esté en el centro de Andalucía para localizarlo mejor (Río de Cabra)
lines.on(M.evt.LOAD, function() {
line = M.filter.EQUAL("cod_rio", "29").execute(lines.getFeatures())[0]
})
// Estilos vacíos (no se visualizarán)
let nullStyleLine = new M.style.Line({});
// Estilos solo color
let colorStyleLine = new M.style.Line({
stroke: {
color: 'red'
}
});
//=============================================================================
// Ejemplos variados de linea
// EJEMPLO CON STROKE
let styleLine = new M.style.Line({
stroke: {
color: '#C8FE2E',
width: 15,
linedash: [1, 20],
linedashoffset: 60,
linecap: 'square',
linejoin: 'miter',
miterlimit: 15
}
});
// EJEMPLO CON STROKE + FILL
let styleLine2 = new M.style.Line({
stroke: {
color: '#C8FE2E',
width: 50,
linedash: [1, 20],
linedashoffset: 60,
linecap: 'square',
linejoin: 'miter',
miterlimit: 15
},
fill: {
color: 'blue',
opacity: 0.7,
width: 15
}
});
// EJEMPLO TEXT
let styleLine3 = new M.style.Line({
label: {
text: '{{nombre}}',
font: 'bold italic 12px Comic Sans MS',
rotate: false,
scale: 0.9,
offset: [10, 20],
color: '#2EFEC8',
stroke: {
color:...
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.