mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Merge pull request #473 from meshtastic/osm-features
add osm map features
This commit is contained in:
commit
97cf35a4e6
11 changed files with 120 additions and 43 deletions
|
|
@ -70,7 +70,7 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
|||
map.let {
|
||||
if (view != null) {
|
||||
mapController = map.controller
|
||||
binding.fabStyleToggle.setOnClickListener {
|
||||
binding.mapStyleButton.setOnClickListener {
|
||||
chooseMapStyle()
|
||||
}
|
||||
model.nodeDB.nodes.value?.let { nodes ->
|
||||
|
|
@ -121,17 +121,22 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
|||
val mrkr = nodesWithPosition.map { node ->
|
||||
val p = node.position!!
|
||||
debug("Showing on map: $node")
|
||||
val f = GeoPoint(p.latitude, p.longitude)
|
||||
lateinit var marker: MarkerWithLabel
|
||||
node.user?.let {
|
||||
val label = it.longName + " " + formatAgo(p.time)
|
||||
marker = MarkerWithLabel(map, label)
|
||||
marker.title = label
|
||||
marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_CENTER)
|
||||
marker.position = f
|
||||
marker.title = buildString {
|
||||
append("$label ${node.batteryStr}\n${model.gpsString(p)}")
|
||||
model.nodeDB.ourNodeInfo?.let { our ->
|
||||
val dist = our.distanceStr(node)
|
||||
if (dist != null) append(" (${our.bearing(node)}° $dist)")
|
||||
}
|
||||
}
|
||||
marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM)
|
||||
marker.position = GeoPoint(p.latitude, p.longitude)
|
||||
marker.icon = ContextCompat.getDrawable(
|
||||
requireActivity(),
|
||||
R.drawable.ic_twotone_person_pin_24
|
||||
R.drawable.ic_twotone_location_on_24
|
||||
)
|
||||
}
|
||||
marker
|
||||
|
|
@ -238,12 +243,12 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
|||
val p = mPositionPixels
|
||||
|
||||
val textPaint = Paint()
|
||||
textPaint.textSize = 50f
|
||||
textPaint.textSize = 40f
|
||||
textPaint.color = Color.RED
|
||||
textPaint.isAntiAlias = true
|
||||
textPaint.textAlign = Paint.Align.CENTER
|
||||
|
||||
c.drawText(mLabel, (p.x - 0).toFloat(), (p.y - 60).toFloat(), textPaint)
|
||||
c.drawText(mLabel, (p.x - 0f), (p.y - 80f), textPaint)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,15 +114,9 @@ class UsersFragment : ScreenFragment("Users"), Logging {
|
|||
|
||||
val pos = n.validPosition
|
||||
if (pos != null) {
|
||||
val coords =
|
||||
String.format("%.5f %.5f", pos.latitude, pos.longitude).replace(",", ".")
|
||||
val html =
|
||||
"<a href='geo:${pos.latitude},${pos.longitude}?z=17&label=${
|
||||
URLEncoder.encode(
|
||||
name,
|
||||
"utf-8"
|
||||
)
|
||||
}'>${coords}</a>"
|
||||
val html = "<a href='geo:${pos.latitude},${pos.longitude}?z=17&label=${
|
||||
URLEncoder.encode(name, "utf-8")
|
||||
}'>${model.gpsString(pos)}</a>"
|
||||
holder.coordsView.text = HtmlCompat.fromHtml(html, HtmlCompat.FROM_HTML_MODE_LEGACY)
|
||||
holder.coordsView.movementMethod = LinkMovementMethod.getInstance()
|
||||
holder.coordsView.visibility = View.VISIBLE
|
||||
|
|
@ -138,7 +132,7 @@ class UsersFragment : ScreenFragment("Users"), Logging {
|
|||
} else {
|
||||
holder.distanceView.visibility = View.INVISIBLE
|
||||
}
|
||||
renderBattery(n.batteryPctLevel, n.deviceMetrics?.voltage, holder)
|
||||
renderBattery(n.batteryLevel, n.voltage, holder)
|
||||
|
||||
holder.lastTime.text = formatAgo(n.lastHeard)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue