Skip to main content

I'm using the HTMLReportGenerator to display a map with points. In the "Label Attribute" setting I've combined several attributes. I want the points that contains a certain word to be in a certain color. In my example I have two different words that should determine the color, "KFF" and "SBF".

 

The label attribute is a long string containing these and some other values ("Example: {3553} KFF). Is there a way you can achieve this with StringReplacer? If feature.properties.name contains KFF than set the color to red else set the color to green.

Maybe you could use an AttributeCreator to create the attribute 'color' and set the value with Conditional Value and then use Operator Contains Regex to search for KFF to set the color to red.

Your Regular Expression is not to difficult, as you are searching for a very specific string.

Below the answer shown in one single screenshot 🙂

HTH,

Egge-Jan

P.S. of course, the Operator Contains should work as well...

conditional_values


Maybe you could use an AttributeCreator to create the attribute 'color' and set the value with Conditional Value and then use Operator Contains Regex to search for KFF to set the color to red.

Your Regular Expression is not to difficult, as you are searching for a very specific string.

Below the answer shown in one single screenshot 🙂

HTH,

Egge-Jan

P.S. of course, the Operator Contains should work as well...

conditional_values

Thanks for the reply! 

From what I see in the HTML that is generated the color that is chosen in the "Layer color" is written out like this:

],
            {
                onEachFeature: function (feature, layer) {
                    layer.bindPopup(feature.properties.popupContent);
                },
                style:{"color": "rgb(170,0,0)"},
                pane: "labels"
            }).addTo(map);
         map.fitBounds(layer.getBounds());
      </script>

The points in the map are however always displayed in blue. So how do I change the color of the points in the HTML? 

image


Ah, you are using Leaflet - a JavaScript library for interactive maps (leafletjs.com). And in your map you are using the default leaflet markers.

I think you should go and try to use CircleMarkers.

Something like:

function styleL1(feature) {
return {
fillColor: '#000080',
color: "#C0C0C0",
weight: 1,
opacity: 1,
fillOpacity: 1
};
}

and

var nlStations = L.Proj.geoJson(nl_stations, {
attribution: proRailSpoordataAttr,
pointToLayer: function (feature, latlng) {
return L.circleMarker(latlng, styleL1(feature));
},
onEachFeature: onEachFeatureL1
}).addTo(map);

With conditional styling of course...

 

HTH,

 

Egge-Jan


Reply