From 1eb6f20597c18829d957b550f732e5f7f2962d68 Mon Sep 17 00:00:00 2001 From: Fynn Godau Date: Fri, 4 Aug 2023 11:24:21 +0200 Subject: [PATCH] Complete polygon stroke --- .../microg/gms/maps/mapbox/model/Polygon.kt | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Polygon.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Polygon.kt index f67d21fe67..c5c205ed23 100644 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Polygon.kt +++ b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Polygon.kt @@ -191,11 +191,15 @@ class PolygonImpl(private val map: GoogleMapImpl, id: String, options: PolygonOp override val strokes = (listOf( PolylineImpl( - map, "$id-stroke-main", PolylineOptions().color(strokeColor).width(strokeWidth).addAll(points) + map, "$id-stroke-main", PolylineOptions().color(strokeColor).width(strokeWidth).addAll( + (points + points.firstOrNull()).filterNotNull() + ) ) - ) + holes.mapIndexed { idx, it -> + ) + holes.mapIndexed { idx, holePoints -> PolylineImpl( - map, "$id-stroke-hole-$idx", PolylineOptions().color(strokeColor).width(strokeWidth).addAll(it) + map, "$id-stroke-hole-$idx", PolylineOptions().color(strokeColor).width(strokeWidth).addAll( + (holePoints + holePoints.firstOrNull()).filterNotNull() + ) ) }).toMutableList() @@ -233,11 +237,15 @@ class LitePolygonImpl(id: String, options: PolygonOptions, private val map: Lite override val strokes: MutableList = (listOf( LitePolylineImpl( - map, "$id-stroke-main", PolylineOptions().color(strokeColor).width(strokeWidth).addAll(points) + map, "$id-stroke-main", PolylineOptions().color(strokeColor).width(strokeWidth).addAll( + (points + points.firstOrNull()).filterNotNull() + ) ) - ) + holes.mapIndexed { idx, it -> + ) + holes.mapIndexed { idx, holePoints -> LitePolylineImpl( - map, "$id-stroke-hole-$idx", PolylineOptions().color(strokeColor).width(strokeWidth).addAll(it) + map, "$id-stroke-hole-$idx", PolylineOptions().color(strokeColor).width(strokeWidth).addAll( + (holePoints + holePoints.firstOrNull()).filterNotNull() + ) ) }).toMutableList()