diff --git a/app/src/main/java/com/mirenkov/ktheightmap/MapCanvas.kt b/app/src/main/java/com/mirenkov/ktheightmap/MapCanvas.kt index fd78007..f8494bf 100644 --- a/app/src/main/java/com/mirenkov/ktheightmap/MapCanvas.kt +++ b/app/src/main/java/com/mirenkov/ktheightmap/MapCanvas.kt @@ -39,9 +39,9 @@ fun distanceString(targetMeters: Int): AnnotatedString { withStyle(ParagraphStyle(textAlign = TextAlign.Center)) { withStyle(SpanStyle(color = Color.White)) { val text = if (targetMeters >= 100000) - "${targetMeters / 1000}km" + "↔${targetMeters / 1000}km" else - "${targetMeters}m" + "↔${targetMeters}m" append(text) } } @@ -222,13 +222,12 @@ fun MapCanvas( end = Offset(halvedX, halvedY) ) - val startHeight = KhmParser.getHeight(pointLon, pointLat, ctx) if (pointOffsetX >= 0 && pointOffsetY >= 0 && pointOffsetX < size.width && pointOffsetY < size.height) drawText( textMeasurer = textMeasurer, text = buildAnnotatedString { withStyle(SpanStyle(color = Color.White)) { - append("${startHeight}m") + append("↑${startHeight}m") } }, topLeft = Offset(pointOffsetX, pointOffsetY - 32) ) @@ -268,7 +267,7 @@ fun MapCanvas( text = distanceString(lineMeters), size = Size(160F, 48F), topLeft = Offset( - halvedX, + halvedX - 80F, halvedY - 80F ) ) @@ -291,15 +290,19 @@ fun MapCanvas( style = Stroke(width = 6F) ) // Height under cursor - drawText( - textMeasurer = textMeasurer, - text = buildAnnotatedString { - withStyle(SpanStyle(color = Color.White)) { - append("${KhmParser.getHeight(lon, lat, ctx)}m") - } - }, - topLeft = Offset(halvedX + crossRadius, halvedY + crossRadius) - ) + KhmParser.getHeight(lon, lat, ctx).let { + if (it < 1u) return@let + drawText( + textMeasurer = textMeasurer, + text = buildAnnotatedString { + withStyle(SpanStyle(color = Color.White)) { + append("↑${it}m") + } + }, + topLeft = Offset(halvedX, halvedY + crossRadius) + ) + } + // Info box drawRect( @@ -307,7 +310,6 @@ fun MapCanvas( size = latLonSize, topLeft = latLonOffset ) - // Info box content drawText( textMeasurer = textMeasurer, @@ -336,14 +338,12 @@ fun MapCanvas( relativeLineTo(-2F * targetPixels.toFloat(), 0F) close() } - // Distance measurer drawPath( measurerPath, Color.White, style = Stroke(width = 6F) ) - // Distance measurer text drawText( textMeasurer = textMeasurer,