You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to get layers to have different styles based on the property of a numeric field.
In QGIS I am using Symbology - Rule based
I have used
Style A "Progress" = >10 and "Progress" <20
Style B "Progress" >=20 and "Progress" < 30 etc
Progress is an integer.
I have also tried
"Progress" BETWEEN 10 AND 20
"Progress" BETWEEN 20 AND 30
Both work fine in QGIS
In Leaflet the expression the result from the qgis2web expression evaluator
exp_LayerNameXX_13rule0_eval_expression(context) is not returning a value that gives the correct style for these ranges.
This results in some features beng styled with the the wrong style or the ELSE style if it is set.
// Start of if blocks and style check logic
if (exp_Layer_13rule0_eval_expression(context)) {
return {
pane: 'pane_Layer_13',
opacity: 1,
color: 'rgba(35,35,35,1.0)',
dashArray: '',
lineCap: 'butt',
lineJoin: 'miter',
weight: 2.0,
fill: true,
fillOpacity: 1,
fillColor: 'rgba(214,131,36,0.48627450980392156)',
interactive: true,
};
}
else if (exp_Layer_13rule1_eval_expression(context)) {
return {
pane: 'pane_Layer_13',
function exp_Layer_13rule1_eval_expression(context) {
// "Progress" > 2019
var feature = context.feature;
if (feature.properties) {
return (feature.properties['Progress'] > 2019);
} else {
return (feature['Progress'] > 2019);
}
}
function exp_Layer_13rule2_eval_expression(context) {
// "Progress" BETWEEN 2010 AND 2019
var feature = context.feature;
if (feature.properties) {
return (feature.properties['Progress'] > 2019);
} else {
return (feature['Progress'] > 2019);
}
}
function exp_Layer_13rule3_eval_expression(context) {
// "Progress" BETWEEN 2000 AND 2009
var feature = context.feature;
if (feature.properties) {
return (feature.properties['Progress'] > 2019);
} else {
return (feature['Progress'] > 2019); 2 and 3 return same result as Rule 1
}
}
if qgis2webexpressions.js is edited as below
function exp_Layer_13rule2_eval_expression(context) {
// "Progress" BETWEEN 2010 AND 2019
var feature = context.feature;
if (feature.properties) {
return (feature.properties['Progress'] == 2010);
} else {
return (feature['Progress'] == 2010);
}
}
This gives the correct styling.
The text was updated successfully, but these errors were encountered:
I am trying to get layers to have different styles based on the property of a numeric field.
In QGIS I am using Symbology - Rule based
I have used
Style A "Progress" = >10 and "Progress" <20
Style B "Progress" >=20 and "Progress" < 30 etc
Progress is an integer.
I have also tried
"Progress" BETWEEN 10 AND 20
"Progress" BETWEEN 20 AND 30
Both work fine in QGIS
In Leaflet the expression the result from the qgis2web expression evaluator
exp_LayerNameXX_13rule0_eval_expression(context) is not returning a value that gives the correct style for these ranges.
This results in some features beng styled with the the wrong style or the ELSE style if it is set.
.........
fillColor: 'rgba(97,97,97,0.47058823529411764)',
interactive: true,
};
}
else if (exp_Layer_13rule2_eval_expression(context)) {
etc
Looking at the generated qgis2webexpressions.js
function exp_Layer_13rule1_eval_expression(context) {
// "Progress" > 2019
}
function exp_Layer_13rule2_eval_expression(context) {
// "Progress" BETWEEN 2010 AND 2019
}
function exp_Layer_13rule3_eval_expression(context) {
// "Progress" BETWEEN 2000 AND 2009
}
if qgis2webexpressions.js is edited as below
function exp_Layer_13rule2_eval_expression(context) {
// "Progress" BETWEEN 2010 AND 2019
}
This gives the correct styling.
The text was updated successfully, but these errors were encountered: