Skip to content

Commit 0cf38fe

Browse files
authored
Fix style expression not supersede its constant values (#969)
1 parent 8ba83de commit 0cf38fe

14 files changed

+233
-338
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### main
22

3+
* Fixed an issue where style expressions did not override constant values when both were present.
34
* [ios] Fix crash when force unwrapping UIImage for point annotations.
45

56
### 2.9.0-rc.1

lib/src/style/layer/background_layer.dart

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,37 +87,32 @@ class BackgroundLayer extends Layer {
8787
var paint = {};
8888
if (backgroundColorExpression != null) {
8989
paint["background-color"] = backgroundColorExpression;
90-
}
91-
if (backgroundColor != null) {
90+
} else if (backgroundColor != null) {
9291
paint["background-color"] = backgroundColor?.toRGBA();
9392
}
9493

9594
if (backgroundEmissiveStrengthExpression != null) {
9695
paint["background-emissive-strength"] =
9796
backgroundEmissiveStrengthExpression;
98-
}
99-
if (backgroundEmissiveStrength != null) {
97+
} else if (backgroundEmissiveStrength != null) {
10098
paint["background-emissive-strength"] = backgroundEmissiveStrength;
10199
}
102100

103101
if (backgroundOpacityExpression != null) {
104102
paint["background-opacity"] = backgroundOpacityExpression;
105-
}
106-
if (backgroundOpacity != null) {
103+
} else if (backgroundOpacity != null) {
107104
paint["background-opacity"] = backgroundOpacity;
108105
}
109106

110107
if (backgroundPatternExpression != null) {
111108
paint["background-pattern"] = backgroundPatternExpression;
112-
}
113-
if (backgroundPattern != null) {
109+
} else if (backgroundPattern != null) {
114110
paint["background-pattern"] = backgroundPattern;
115111
}
116112

117113
if (backgroundPitchAlignmentExpression != null) {
118114
paint["background-pitch-alignment"] = backgroundPitchAlignmentExpression;
119-
}
120-
if (backgroundPitchAlignment != null) {
115+
} else if (backgroundPitchAlignment != null) {
121116
paint["background-pitch-alignment"] =
122117
backgroundPitchAlignment?.name.toLowerCase().replaceAll("_", "-");
123118
}

lib/src/style/layer/circle_layer.dart

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -200,87 +200,75 @@ class CircleLayer extends Layer {
200200
var paint = {};
201201
if (circleBlurExpression != null) {
202202
paint["circle-blur"] = circleBlurExpression;
203-
}
204-
if (circleBlur != null) {
203+
} else if (circleBlur != null) {
205204
paint["circle-blur"] = circleBlur;
206205
}
207206

208207
if (circleColorExpression != null) {
209208
paint["circle-color"] = circleColorExpression;
210-
}
211-
if (circleColor != null) {
209+
} else if (circleColor != null) {
212210
paint["circle-color"] = circleColor?.toRGBA();
213211
}
214212

215213
if (circleEmissiveStrengthExpression != null) {
216214
paint["circle-emissive-strength"] = circleEmissiveStrengthExpression;
217-
}
218-
if (circleEmissiveStrength != null) {
215+
} else if (circleEmissiveStrength != null) {
219216
paint["circle-emissive-strength"] = circleEmissiveStrength;
220217
}
221218

222219
if (circleOpacityExpression != null) {
223220
paint["circle-opacity"] = circleOpacityExpression;
224-
}
225-
if (circleOpacity != null) {
221+
} else if (circleOpacity != null) {
226222
paint["circle-opacity"] = circleOpacity;
227223
}
228224

229225
if (circlePitchAlignmentExpression != null) {
230226
paint["circle-pitch-alignment"] = circlePitchAlignmentExpression;
231-
}
232-
if (circlePitchAlignment != null) {
227+
} else if (circlePitchAlignment != null) {
233228
paint["circle-pitch-alignment"] =
234229
circlePitchAlignment?.name.toLowerCase().replaceAll("_", "-");
235230
}
236231

237232
if (circlePitchScaleExpression != null) {
238233
paint["circle-pitch-scale"] = circlePitchScaleExpression;
239-
}
240-
if (circlePitchScale != null) {
234+
} else if (circlePitchScale != null) {
241235
paint["circle-pitch-scale"] =
242236
circlePitchScale?.name.toLowerCase().replaceAll("_", "-");
243237
}
244238

245239
if (circleRadiusExpression != null) {
246240
paint["circle-radius"] = circleRadiusExpression;
247-
}
248-
if (circleRadius != null) {
241+
} else if (circleRadius != null) {
249242
paint["circle-radius"] = circleRadius;
250243
}
251244

252245
if (circleStrokeColorExpression != null) {
253246
paint["circle-stroke-color"] = circleStrokeColorExpression;
254-
}
255-
if (circleStrokeColor != null) {
247+
} else if (circleStrokeColor != null) {
256248
paint["circle-stroke-color"] = circleStrokeColor?.toRGBA();
257249
}
258250

259251
if (circleStrokeOpacityExpression != null) {
260252
paint["circle-stroke-opacity"] = circleStrokeOpacityExpression;
261-
}
262-
if (circleStrokeOpacity != null) {
253+
} else if (circleStrokeOpacity != null) {
263254
paint["circle-stroke-opacity"] = circleStrokeOpacity;
264255
}
265256

266257
if (circleStrokeWidthExpression != null) {
267258
paint["circle-stroke-width"] = circleStrokeWidthExpression;
268-
}
269-
if (circleStrokeWidth != null) {
259+
} else if (circleStrokeWidth != null) {
270260
paint["circle-stroke-width"] = circleStrokeWidth;
271261
}
272262

273263
if (circleTranslateExpression != null) {
274264
paint["circle-translate"] = circleTranslateExpression;
275-
}
276-
if (circleTranslate != null) {
265+
} else if (circleTranslate != null) {
277266
paint["circle-translate"] = circleTranslate;
278267
}
279268

280269
if (circleTranslateAnchorExpression != null) {
281270
paint["circle-translate-anchor"] = circleTranslateAnchorExpression;
282-
}
283-
if (circleTranslateAnchor != null) {
271+
} else if (circleTranslateAnchor != null) {
284272
paint["circle-translate-anchor"] =
285273
circleTranslateAnchor?.name.toLowerCase().replaceAll("_", "-");
286274
}

0 commit comments

Comments
 (0)