aboutsummaryrefslogtreecommitdiff
path: root/androidApp
diff options
context:
space:
mode:
Diffstat (limited to 'androidApp')
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt70
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MarkerTransformations.kt3
-rw-r--r--androidApp/src/main/res/values/colors.xml3
-rw-r--r--androidApp/src/main/res/values/dimen.xml4
4 files changed, 53 insertions, 27 deletions
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 9b4d24a..b8fbc57 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
@@ -27,6 +27,7 @@ class MapFragment : GlobeMapFragment() {
data class Marker(
val id: Int,
+ val name: String,
val latitude: Double,
val longitude: Double,
val type: MarkerType = MarkerType.DEFAULT
@@ -74,20 +75,6 @@ class MapFragment : GlobeMapFragment() {
loader = QuadImageLoader(params, tileInfo, baseControl)
loader?.setImageFormat(RenderController.ImageFormat.MaplyImageUShort565)
- val clusterGenerator = BasicClusterGenerator(
- intArrayOf(
- Color.argb(255, 255, 255, 255)
- ), 0, Point2d(64.0, 64.0), baseControl, activity
- )
- clusterGenerator.cacheBitmaps(true)
- clusterGenerator.setExponentBase(2.5)
- clusterGenerator.setTextColor(Color.BLACK)
- clusterGenerator.setLayoutSize(Point2d(80.0, 80.0))
- clusterGenerator.setSelectable(false)
-
- baseControl.clearClusterGenerators()
- baseControl.addClusterGenerator(clusterGenerator)
-
val latitude = 23.191
val longitude = -100.36
focusOn(latitude, longitude, zoom = 0.4, animated = false)
@@ -143,10 +130,22 @@ class MapFragment : GlobeMapFragment() {
Point2d.FromDegrees(marker.longitude, marker.latitude)
}.toTypedArray()
+ val fontSize = context?.resources?.getDimensionPixelSize(R.dimen.marker_label_text_size)
+ val reportColor = ContextCompat.getColor(context!!, R.color.colorReport)
+ val labelColor = ContextCompat.getColor(context!!, R.color.colorMarkerLabel)
+ val labelBgColor = ContextCompat.getColor(context!!, R.color.bgColorMarkerLabel)
+
val vectorInfo = VectorInfo()
- vectorInfo.setColor(ContextCompat.getColor(context!!, R.color.colorReport))
+ vectorInfo.setColor(reportColor)
vectorInfo.setLineWidth(20.0f)
+ val labelInfo = LabelInfo()
+ labelInfo.textColor = labelColor
+ labelInfo.backgroundColor = labelBgColor
+ fontSize?.let {
+ labelInfo.fontSize = it.toFloat()
+ }
+
/* Draw markers for positions */
val screenMarkers = markers.mapIndexed { i, marker ->
val screenMarker = ScreenMarker()
@@ -169,24 +168,36 @@ class MapFragment : GlobeMapFragment() {
} else Point2d(144.0, 144.0)
screenMarker.userObject = marker.id
screenMarker.selectable = true
- if (!isReport) {
- screenMarker.layoutImportance = 1.0f
- }
screenMarker
}
- val markerInfo = MarkerInfo()
- if (!isReport) {
- markerInfo.setClusterGroup(0)
- }
-
objects.add(mapControl.addScreenMarkers(
screenMarkers,
- markerInfo,
+ MarkerInfo(),
ThreadMode.ThreadAny
))
+ /* Add labels for markers */
+ if (!isReport && markers.isNotEmpty()) {
+ val screenLabels = markers.map { marker ->
+ val label = ScreenLabel()
+ label.layoutImportance = Float.MAX_VALUE
+ label.text = if (marker.name.length >= 20) {
+ marker.name.substring(0 until 20) + "..."
+ } else marker.name
+ label.loc = Point2d.FromDegrees(marker.longitude, marker.latitude)
+ label.offset = Point2d(0.0, 92.0)
+ label
+ }
+
+ objects.add(mapControl.addScreenLabels(
+ screenLabels,
+ labelInfo,
+ ThreadMode.ThreadAny
+ ))
+ }
+
/* Draw polyline for report */
if (isReport && markers.isNotEmpty()) {
val vector = VectorObject()
@@ -219,14 +230,19 @@ class MapFragment : GlobeMapFragment() {
clear(true)
- val color = ContextCompat.getColor(context!!, R.color.colorGeofence)
+ val fontSize = context?.resources?.getDimensionPixelSize(R.dimen.marker_label_text_size)
+ val colorFill = ContextCompat.getColor(context!!, R.color.colorGeofence)
+ val colorLabel = ContextCompat.getColor(context!!, R.color.colorGeofenceLabel)
val vectorInfo = VectorInfo()
- vectorInfo.setColor(color)
+ vectorInfo.setColor(colorFill)
vectorInfo.setLineWidth(10.0f)
val labelInfo = LabelInfo()
- labelInfo.textColor = color
+ labelInfo.textColor = colorLabel
+ fontSize?.let {
+ labelInfo.fontSize = it.toFloat()
+ }
val shapes = mutableListOf<Shape>()
val vectors = mutableListOf<VectorObject>()
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MarkerTransformations.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MarkerTransformations.kt
index fcde58d..b1d52fb 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MarkerTransformations.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MarkerTransformations.kt
@@ -13,6 +13,7 @@ object MarkerTransformations {
return MapFragment.Marker(
unit.position!!.id!!,
+ unit.device.name,
unit.position!!.latitude!!,
unit.position!!.longitude!!,
categoryToMarkerType(unit.device.category ?: "")
@@ -26,6 +27,7 @@ object MarkerTransformations {
return MapFragment.Marker(
position.id!!,
+ "",
position.latitude!!,
position.longitude!!
)
@@ -38,6 +40,7 @@ object MarkerTransformations {
return MapFragment.Marker(
stop.deviceId!!,
+ stop.deviceName!!,
stop.lat!!,
stop.lon!!
)
diff --git a/androidApp/src/main/res/values/colors.xml b/androidApp/src/main/res/values/colors.xml
index ee5d167..b241148 100644
--- a/androidApp/src/main/res/values/colors.xml
+++ b/androidApp/src/main/res/values/colors.xml
@@ -6,7 +6,10 @@
<color name="background">#FDFDFD</color>
<color name="darkBackground">#ECEFF3</color>
+ <color name="colorMarkerLabel">#656A74</color>
+ <color name="bgColorMarkerLabel">#FFFFFF</color>
<color name="colorGeofence">#1976D2</color>
+ <color name="colorGeofenceLabel">#1976D2</color>
<color name="colorReport">#388E3C</color>
<color name="colorOnline">#388E3C</color>
diff --git a/androidApp/src/main/res/values/dimen.xml b/androidApp/src/main/res/values/dimen.xml
index 2d0dcc3..a016dbd 100644
--- a/androidApp/src/main/res/values/dimen.xml
+++ b/androidApp/src/main/res/values/dimen.xml
@@ -21,6 +21,10 @@
<dimen name="fab_margin">12dp</dimen>
<dimen name="fab_elevation">8dp</dimen>
+ <!-- Map -->
+ <dimen name="marker_label_text_size">11sp</dimen>
+ <dimen name="geofence_label_text_size">11sp</dimen>
+
<!-- User Information -->
<dimen name="fields_spacing">8dp</dimen>
<dimen name="fields_large_spacing">16dp</dimen>