[Test] IAPH CLuster 5.0.0
by Francisco
HTML
<script src="https://mapea4-sigc.juntadeandalucia.es/js/mapea-5.0.0.ol.min.js"></script>
<link rel="stylesheet" href="https://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>
<button id="cluster" onclick="setStyleCluster()">
Cluster
</button>
<div id="map"></div>
CSS
html,
body {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden;
}
JavaScript
var mapajs = M.map({
container: 'map',
controls: ["layerswitcher", "mouse"],
layers: [new M.layer.Mapbox({
type: "Mapbox",
url: "https://api.mapbox.com/v4/",
name: "mapbox.streets",
legend: "Calles"
})],
bbox: [96388, 3959795, 621889, 4299792],
zoom: 4
});
var campamentos = new M.layer.WFS({
url: "https://www.iaph.es/ide/wfs?",
//namespace: "sepim",
name: "paisaje:PICA_2018,localizador:localizador,inmaterial:inmaterial,pmu:pmu",
geometry: 'POINT',
extract: true
});
mapajs.addLayers(campamentos);
//Estilo para cluster
let clusterOptions = {
ranges: [{
min: 2,
max: 10,
style: new M.style.Point({
stroke: {
color: '#5789aa'
},
fill: {
color: '#99ccff',
},
radius: 20
})
}, {
min: 11,
max: 500,
style: new M.style.Point({
stroke: {
color: '#5789aa'
},
fill: {
color: '#3399ff',
},
radius: 30
})
}, {
min: 501,
max: 1000,
style: new M.style.Point({
stroke: {
color: '#5789aa'
},
fill: {
color: '#004c99',
},
radius: 40
})
}],
animated: true,
hoverInteraction: true,
displayAmount: true,
distance: 80,
maxFeaturesToSelect: 7
};
let vendorParameters = {
distanceSelectFeatures: 25,
convexHullStyle: {
fill: {
color: '#000000',
opacity: 0.5
},
stroke: {
color: '#000000',
width: 1
}
}
}
let clusterStyle = new M.style.Cluster(clusterOptions, vendorParameters);
function setStyleCluster() {
campamentos.setStyle(clusterStyle);
}
...