diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/Pattern.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/Pattern.kt index 646a0906a72c6b82172257b4d72f6bacea806fdb..9cfd084a7173c26c5f5f5bf14156a6096de06bd6 100644 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/Pattern.kt +++ b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/Pattern.kt @@ -18,7 +18,7 @@ fun PatternItem.getName(): String = when (this) { /** * Name of pattern, to identify it after it is added to map */ -fun MutableList.getName(color: Int, strokeWidth: Float) = joinToString("-") { +fun List.getName(color: Int, strokeWidth: Float) = joinToString("-") { it.getName() } + "-${color}-width${strokeWidth}" @@ -37,15 +37,15 @@ fun PatternItem.getWidth(strokeWidth: Float): Float = when (this) { * Gets width that a bitmap for this pattern would have if it were to be drawn * with respect to aspect ratio onto a canvas with height 1. */ -fun MutableList.getWidth(strokeWidth: Float) = map { it.getWidth(strokeWidth) }.sum() +fun List.getWidth(strokeWidth: Float) = map { it.getWidth(strokeWidth) }.sum() -fun MutableList.makeBitmap(color: Int, strokeWidth: Float): Bitmap = makeBitmap(Paint().apply { +fun List.makeBitmap(color: Int, strokeWidth: Float): Bitmap = makeBitmap(Paint().apply { setColor(color) style = Paint.Style.FILL }, strokeWidth) -fun MutableList.makeBitmap(paint: Paint, strokeWidth: Float): Bitmap { +fun List.makeBitmap(paint: Paint, strokeWidth: Float): Bitmap { // Pattern aspect ratio is not respected by renderer val width = getWidth(strokeWidth).toInt() diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Circle.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Circle.kt index 2ff823667ceaef3cfad3dab08e7d5519fc508244..93f3c1d32a8d62e257de8be1794066dc57a15e78 100644 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Circle.kt +++ b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Circle.kt @@ -21,6 +21,7 @@ import android.util.Log import com.google.android.gms.dynamic.IObjectWrapper import com.google.android.gms.dynamic.ObjectWrapper import com.google.android.gms.dynamic.unwrap +import com.google.android.gms.maps.model.Dash import com.google.android.gms.maps.model.LatLng import com.google.android.gms.maps.model.PatternItem import com.google.android.gms.maps.model.internal.ICircleDelegate @@ -284,8 +285,7 @@ class CircleImpl(private val map: GoogleMapImpl, private val id: String, options it.lineWidth = strokeWidth / map.dpiFactor - line.annotation?.linePattern = null - strokePattern?.let { pattern -> + (strokePattern ?: listOf(Dash(1f))).let { pattern -> val bitmapName = pattern.getName(strokeColor, strokeWidth) map.addBitmap(bitmapName, pattern.makeBitmap(strokeColor, strokeWidth)) line.annotation?.linePattern = bitmapName