Support different colors and headings on each feature

We're making sure each feature contains properties in order to avoid
possible JavaScript errors.

We're also adding a default color to a geozone.
This commit is contained in:
CoslaJohn
2024-07-19 12:15:00 +01:00
committed by Javi Martín
parent 5dbe2cbf24
commit cb8b0ad6ff
4 changed files with 59 additions and 11 deletions

View File

@@ -223,14 +223,18 @@
var geojsonData = JSON.parse(geozone.outline_points);
var geoJsonLayer = L.geoJSON(geojsonData, {
style: {
color: geozone.color,
fillOpacity: 0.3,
className: "map-polygon"
style: function(feature) {
return {
color: feature.properties.color || geozone.color,
fillOpacity: 0.3,
className: "map-polygon"
};
},
onEachFeature: function(feature, layer) {
if (geozone.headings) {
layer.bindPopup(geozone.headings.join("<br>"));
var headings = feature.properties.headings || geozone.headings;
if (headings) {
layer.bindPopup(headings.join("<br>"));
}
}
});