diff --git a/app/src/main/java/com/google/maps/android/compose/markerexamples/draggablemarkerscollectionwithpolygon/DraggableMarkersCollectionWithPolygonActivity.kt b/app/src/main/java/com/google/maps/android/compose/markerexamples/draggablemarkerscollectionwithpolygon/DraggableMarkersCollectionWithPolygonActivity.kt index 0faede4bf..268d362fa 100644 --- a/app/src/main/java/com/google/maps/android/compose/markerexamples/draggablemarkerscollectionwithpolygon/DraggableMarkersCollectionWithPolygonActivity.kt +++ b/app/src/main/java/com/google/maps/android/compose/markerexamples/draggablemarkerscollectionwithpolygon/DraggableMarkersCollectionWithPolygonActivity.kt @@ -187,9 +187,7 @@ private fun LocationMarker( private fun Polygon(markerPositionsModel: () -> List<() -> LatLng>) { val movingMarkerPositions = markerPositionsModel() - if (movingMarkerPositions.isNotEmpty()) { - val markerPositions = movingMarkerPositions.map { it() } + val markerPositions = movingMarkerPositions.map { it() } - Polygon(markerPositions) - } + Polygon(markerPositions) } diff --git a/maps-compose/src/main/java/com/google/maps/android/compose/Polygon.kt b/maps-compose/src/main/java/com/google/maps/android/compose/Polygon.kt index 4eb4e01da..147d1833d 100644 --- a/maps-compose/src/main/java/com/google/maps/android/compose/Polygon.kt +++ b/maps-compose/src/main/java/com/google/maps/android/compose/Polygon.kt @@ -68,6 +68,8 @@ public fun Polygon( zIndex: Float = 0f, onClick: (Polygon) -> Unit = {} ) { + if (points.isEmpty()) return // avoid SDK crash + val mapApplier = currentComposer.applier as MapApplier? ComposeNode( factory = {