Skip to content

Commit 1310804

Browse files
authored
fix: avoid Polygon crash on empty list of points (#667)
Fixes #666 Co-authored-by: Uli Bubenheimer <[email protected]>
1 parent 17af9d1 commit 1310804

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

app/src/main/java/com/google/maps/android/compose/markerexamples/draggablemarkerscollectionwithpolygon/DraggableMarkersCollectionWithPolygonActivity.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,7 @@ private fun LocationMarker(
187187
private fun Polygon(markerPositionsModel: () -> List<() -> LatLng>) {
188188
val movingMarkerPositions = markerPositionsModel()
189189

190-
if (movingMarkerPositions.isNotEmpty()) {
191-
val markerPositions = movingMarkerPositions.map { it() }
190+
val markerPositions = movingMarkerPositions.map { it() }
192191

193-
Polygon(markerPositions)
194-
}
192+
Polygon(markerPositions)
195193
}

maps-compose/src/main/java/com/google/maps/android/compose/Polygon.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public fun Polygon(
6868
zIndex: Float = 0f,
6969
onClick: (Polygon) -> Unit = {}
7070
) {
71+
if (points.isEmpty()) return // avoid SDK crash
72+
7173
val mapApplier = currentComposer.applier as MapApplier?
7274
ComposeNode<PolygonNode, MapApplier>(
7375
factory = {

0 commit comments

Comments
 (0)