From 5dd2bf01865705f5ee74374472895ffed30f2b26 Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Tue, 11 Jan 2022 15:24:22 -0600 Subject: Shows geofence names on map --- .../TrackerMap/android/map/MapFragment.kt | 26 ++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'androidApp/src/main/java/mx/trackermap') diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt index f87d89a..39312a8 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt @@ -136,6 +136,7 @@ class MapFragment : GlobeMapFragment() { screenMarker.loc = Point2d.FromDegrees(marker.longitude, marker.latitude) screenMarker.image = if (isReport) { + // For reports, position, start and end markers must be shown differently when (i) { 0 -> getIcon(MarkerType.REPORT_START) markers.size - 1 -> getIcon(MarkerType.REPORT_END) @@ -195,12 +196,16 @@ class MapFragment : GlobeMapFragment() { clear(true) - val vectorInfoGeofence = VectorInfo() - vectorInfoGeofence.setColor(Color.BLUE) - vectorInfoGeofence.setLineWidth(10.0f) + val vectorInfo = VectorInfo() + vectorInfo.setColor(Color.BLUE) + vectorInfo.setLineWidth(10.0f) + + val labelInfo = LabelInfo() + labelInfo.textColor = Color.BLUE val shapes = mutableListOf() val vectors = mutableListOf() + val labels = mutableListOf() geofences.forEach { geofence -> geofence.area?.let { area -> @@ -216,6 +221,13 @@ class MapFragment : GlobeMapFragment() { }.toTypedArray()) vectors.add(vector) + + val label = ScreenLabel() + label.text = geofence.name + label.loc = Point2d.FromDegrees(geometry.centroid.y, geometry.centroid.x) + label.layoutImportance = Float.MAX_VALUE + + labels.add(label) } } } @@ -233,7 +245,13 @@ class MapFragment : GlobeMapFragment() { geofenceObjects.add(mapControl.addVectors( vectors, - vectorInfoGeofence, + vectorInfo, + ThreadMode.ThreadAny + )) + + geofenceObjects.add(mapControl.addScreenLabels( + labels, + labelInfo, ThreadMode.ThreadAny )) } -- cgit v1.2.3