Added satellite dots to increase visibility on the map

This commit is contained in:
Arty Bishop committed 2022-02-24 18:24:45 +00:00
1 parent 03323172ea
commit 89be2dfa43
2 files changed
+27 -11

No files matched your search

@@ -18,10 +18,9 @@
package com.rtbishop.look4sat.presentation.mapScreen package com.rtbishop.look4sat.presentation.mapScreen
import android.content.Context import android.content.Context
import android.graphics.Color import android.graphics.*
import android.graphics.ColorMatrix import android.graphics.drawable.BitmapDrawable
import android.graphics.ColorMatrixColorFilter import android.graphics.drawable.Drawable
import android.graphics.Paint
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
@@ -63,6 +62,14 @@ class MapFragment : Fragment(R.layout.fragment_map) {
style = Paint.Style.FILL_AND_STROKE style = Paint.Style.FILL_AND_STROKE
color = Color.parseColor("#FFE082") color = Color.parseColor("#FFE082")
} }
private val textPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
textSize = 28f
strokeWidth = 2f
style = Paint.Style.FILL
color = Color.parseColor("#FFE082")
setShadowLayer(3f, 3f, 3f, Color.BLACK)
}
private val labelRect = Rect()
private lateinit var binding: FragmentMapBinding private lateinit var binding: FragmentMapBinding
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@@ -125,12 +132,8 @@ class MapFragment : Fragment(R.layout.fragment_map) {
posMap.entries.forEach { posMap.entries.forEach {
Marker(mapView).apply { Marker(mapView).apply {
setInfoWindow(null) setInfoWindow(null)
textLabelFontSize = 28
textLabelBackgroundColor = Color.TRANSPARENT
textLabelForegroundColor =
ContextCompat.getColor(requireContext(), R.color.accent)
setTextIcon(it.key.data.name)
setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_CENTER) setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_CENTER)
icon = getCustomTextIcon(it.key.data.name)
try { try {
position = GeoPoint(it.value.latitude, it.value.longitude) position = GeoPoint(it.value.latitude, it.value.longitude)
} catch (exception: IllegalArgumentException) { } catch (exception: IllegalArgumentException) {
@@ -148,6 +151,19 @@ class MapFragment : Fragment(R.layout.fragment_map) {
} }
} }
private fun getCustomTextIcon(textLabel: String): Drawable {
textPaint.getTextBounds(textLabel, 0, textLabel.length, labelRect)
val iconSize = 8f
val width = labelRect.width() + iconSize * 2f
val height = textPaint.textSize * 3f + iconSize * 2f
val bitmap = Bitmap.createBitmap(width.toInt(), height.toInt(), Bitmap.Config.ARGB_8888)
Canvas(bitmap).run {
drawCircle(width / 2f, height / 2f, iconSize, textPaint)
drawText(textLabel, iconSize / 2f, height - iconSize, textPaint)
}
return BitmapDrawable(binding.mapView.context.resources, bitmap)
}
private fun handleTrack(satTrack: List<List<GeoPos>>) { private fun handleTrack(satTrack: List<List<GeoPos>>) {
val trackOverlay = FolderOverlay() val trackOverlay = FolderOverlay()
satTrack.forEach { track -> satTrack.forEach { track ->
+2 -2
View File
@@ -6,8 +6,8 @@ buildscript {
} }
plugins { plugins {
id "com.android.application" version "7.1.1" apply false id "com.android.application" version '7.1.2' apply false
id "com.android.library" version "7.1.1" apply false id "com.android.library" version '7.1.2' apply false
id "org.jetbrains.kotlin.android" version "1.6.10" apply false id "org.jetbrains.kotlin.android" version "1.6.10" apply false
} }