Skip to content

Commit

Permalink
use colors
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaGeo committed Oct 2, 2023
1 parent 99f98ab commit 10aa265
Showing 1 changed file with 43 additions and 12 deletions.
55 changes: 43 additions & 12 deletions radon/radon.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,55 @@
url: "radon_v2.pmtiles",
attributions: ["© British Geological Survey"]
}),
style: new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'red',
width: 1,
}),
fill: new ol.style.Fill({
color: 'rgba(240,0,0,1)',
})
})
style: function (feature) {
// Get the "CLASS_MAX" attribute value from the feature's properties
const classMax = feature.get("CLASS_MAX");

// Define your style categories and corresponding styles here
// Adjust the conditions and styles to match your data
if (classMax === 1) {
return new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'red',
width: 1,
}),
fill: new ol.style.Fill({
color: 'rgba(240, 0, 0, 1)',
})
});
} else if (classMax === 2) {
return new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'blue',
width: 1,
}),
fill: new ol.style.Fill({
color: 'rgba(0, 0, 240, 1)',
})
});
}
// Add more conditions and styles for other attribute values as needed

// Default style if no condition matches
return new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'gray',
width: 1,
}),
fill: new ol.style.Fill({
color: 'rgba(128, 128, 128, 1)',
})
});
}
});

ol.proj.useGeographic();
const map = new ol.Map({
layers: [vectorLayer],
target: 'map',
view: new ol.View({
center: [1.4,53.1],
zoom: 7
center: [1.4, 53.1],
zoom: 5
}),
});
</script>
Expand Down

0 comments on commit 10aa265

Please sign in to comment.