// CP-070-03 - StylePolygon (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.
// constructor del mapa
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 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 polygon = null;
//Seleccionamos un polígono que esté en el centro de Andalucía para localizarlo mejor (SANTAELLA)
polygons.on(M.evt.LOAD, function() {
polygon = M.filter.EQUAL("cod_ine_municipio","14060").execute(polygons.getFeatures())[0];
})
// Set estilo null
function setStyleNull() {
polygons.setStyle( null );
}
function setStyleVacio() {
polygons.setStyle( );
}
// Estilos vacíos (no se visualizarán)
let nullStylePolygon = new M.style.Polygon();
// Estilos solo color
let colorStylePolygon = new M.style.Polygon({
fill: {
color: 'red'
}
});
// Estilos stroke
let strokeStylePolygon = new M.style.Polygon({
stroke: {
color: 'red'
}
});
//=============================================================================
// Estilos variados de polígonos
// EJEMPLO STROKE
let stylePolygon = new M.style.Polygon({
stroke: {
color: '#C8FE2E',
width: 15,
linedash: [1, 20],
linedashoffset: 60,
linecap: 'square',
linejoin: 'miter',
miterlimit: 15
}
});
// EJEMPLO FILL
let stylePolygon2 = new M.style.Polygon({
fill: {
color: '#6A0888',
opacity: 0.5
}
});
// EJEMPLO FILL - PATTERN
let stylePolygon3 = new M.style.Polygon({
stroke: {
color: '#C8FE2E',
...
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.