Skip to content

Commit 3f57fcd

Browse files
authored
Backport bug fixes (#973)
* [iOS] Fix crash when force unwrapping image for point annotation (#970) * Fix style expression not supersede its constant values (#969)
1 parent 4cde0ae commit 3f57fcd

15 files changed

+304
-336
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
> * `PointAnnotation.iconImageCrossFade` has been deprecated and setting a value to it will not have any impact. Use `PointAnnotationManager.iconImageCrossFade` instead.
77
> * The STANDARD_EXPERIMENTAL style has been removed. Use the STANDARD style instead.
88
9+
* Fixed an issue where style expressions did not override constant values when both were present.
10+
* [ios] Fix crash when force unwrapping UIImage for point annotations.
911
* In this release we fixed a bug in our Android conversion code where the property values in `StylePropertyValue` were being returned as strings rather than their actual type. This fix will cause a behavioral change in the return value of the following methods on Android:
1012
* `getStyleImportConfigProperties`, `getStyleImportConfigProperty`, `getStyleLayerProperty`, `getStyleSourceProperty`, `getStyleTerrainProperty`, `getStyleLightProperty`.
1113
* Expose new methods for working with style imports: `addStyleImportFromJSON`, `addStyleImportFromURI`, `updateStyleImportWithJSON`, `updateStyleImportWithURI`, and `moveStyleImport`.

ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Annotations/PointAnnotationController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,8 +1351,8 @@ extension PointAnnotation {
13511351

13521352
func toPointAnnotation() -> MapboxMaps.PointAnnotation {
13531353
var annotation = MapboxMaps.PointAnnotation(id: self.id, point: geometry)
1354-
if let image = self.image {
1355-
annotation.image = .init(image: UIImage(data: image.data, scale: UIScreen.main.scale)!, name: iconImage ?? UUID().uuidString)
1354+
if let image = image, let uiImage = UIImage(data: image.data, scale: UIScreen.main.scale) {
1355+
annotation.image = .init(image: uiImage, name: iconImage ?? UUID().uuidString)
13561356
}
13571357
if let iconAnchor {
13581358
annotation.iconAnchor = MapboxMaps.IconAnchor(iconAnchor)

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
@@ -180,87 +180,75 @@ class CircleLayer extends Layer {
180180
var paint = {};
181181
if (circleBlurExpression != null) {
182182
paint["circle-blur"] = circleBlurExpression;
183-
}
184-
if (circleBlur != null) {
183+
} else if (circleBlur != null) {
185184
paint["circle-blur"] = circleBlur;
186185
}
187186

188187
if (circleColorExpression != null) {
189188
paint["circle-color"] = circleColorExpression;
190-
}
191-
if (circleColor != null) {
189+
} else if (circleColor != null) {
192190
paint["circle-color"] = circleColor?.toRGBA();
193191
}
194192

195193
if (circleEmissiveStrengthExpression != null) {
196194
paint["circle-emissive-strength"] = circleEmissiveStrengthExpression;
197-
}
198-
if (circleEmissiveStrength != null) {
195+
} else if (circleEmissiveStrength != null) {
199196
paint["circle-emissive-strength"] = circleEmissiveStrength;
200197
}
201198

202199
if (circleOpacityExpression != null) {
203200
paint["circle-opacity"] = circleOpacityExpression;
204-
}
205-
if (circleOpacity != null) {
201+
} else if (circleOpacity != null) {
206202
paint["circle-opacity"] = circleOpacity;
207203
}
208204

209205
if (circlePitchAlignmentExpression != null) {
210206
paint["circle-pitch-alignment"] = circlePitchAlignmentExpression;
211-
}
212-
if (circlePitchAlignment != null) {
207+
} else if (circlePitchAlignment != null) {
213208
paint["circle-pitch-alignment"] =
214209
circlePitchAlignment?.name.toLowerCase().replaceAll("_", "-");
215210
}
216211

217212
if (circlePitchScaleExpression != null) {
218213
paint["circle-pitch-scale"] = circlePitchScaleExpression;
219-
}
220-
if (circlePitchScale != null) {
214+
} else if (circlePitchScale != null) {
221215
paint["circle-pitch-scale"] =
222216
circlePitchScale?.name.toLowerCase().replaceAll("_", "-");
223217
}
224218

225219
if (circleRadiusExpression != null) {
226220
paint["circle-radius"] = circleRadiusExpression;
227-
}
228-
if (circleRadius != null) {
221+
} else if (circleRadius != null) {
229222
paint["circle-radius"] = circleRadius;
230223
}
231224

232225
if (circleStrokeColorExpression != null) {
233226
paint["circle-stroke-color"] = circleStrokeColorExpression;
234-
}
235-
if (circleStrokeColor != null) {
227+
} else if (circleStrokeColor != null) {
236228
paint["circle-stroke-color"] = circleStrokeColor?.toRGBA();
237229
}
238230

239231
if (circleStrokeOpacityExpression != null) {
240232
paint["circle-stroke-opacity"] = circleStrokeOpacityExpression;
241-
}
242-
if (circleStrokeOpacity != null) {
233+
} else if (circleStrokeOpacity != null) {
243234
paint["circle-stroke-opacity"] = circleStrokeOpacity;
244235
}
245236

246237
if (circleStrokeWidthExpression != null) {
247238
paint["circle-stroke-width"] = circleStrokeWidthExpression;
248-
}
249-
if (circleStrokeWidth != null) {
239+
} else if (circleStrokeWidth != null) {
250240
paint["circle-stroke-width"] = circleStrokeWidth;
251241
}
252242

253243
if (circleTranslateExpression != null) {
254244
paint["circle-translate"] = circleTranslateExpression;
255-
}
256-
if (circleTranslate != null) {
245+
} else if (circleTranslate != null) {
257246
paint["circle-translate"] = circleTranslate;
258247
}
259248

260249
if (circleTranslateAnchorExpression != null) {
261250
paint["circle-translate-anchor"] = circleTranslateAnchorExpression;
262-
}
263-
if (circleTranslateAnchor != null) {
251+
} else if (circleTranslateAnchor != null) {
264252
paint["circle-translate-anchor"] =
265253
circleTranslateAnchor?.name.toLowerCase().replaceAll("_", "-");
266254
}

0 commit comments

Comments
 (0)