aboutsummaryrefslogtreecommitdiff
path: root/androidApp/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'androidApp/src/main')
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesFragment.kt1
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt64
-rw-r--r--androidApp/src/main/res/drawable/map_animal.pngbin0 -> 1074 bytes
-rw-r--r--androidApp/src/main/res/drawable/map_bicycle.pngbin0 -> 1121 bytes
-rw-r--r--androidApp/src/main/res/drawable/map_boat.pngbin0 -> 1066 bytes
-rw-r--r--androidApp/src/main/res/drawable/map_bus.pngbin0 -> 1012 bytes
-rw-r--r--androidApp/src/main/res/drawable/map_car.pngbin0 -> 1025 bytes
-rw-r--r--androidApp/src/main/res/drawable/map_crane.pngbin0 -> 1106 bytes
-rw-r--r--androidApp/src/main/res/drawable/map_helicopter.pngbin0 -> 1042 bytes
-rw-r--r--androidApp/src/main/res/drawable/map_motorcycle.pngbin0 -> 1123 bytes
-rw-r--r--androidApp/src/main/res/drawable/map_offroad.pngbin0 -> 1031 bytes
-rw-r--r--androidApp/src/main/res/drawable/map_person.pngbin0 -> 957 bytes
-rw-r--r--androidApp/src/main/res/drawable/map_pickup.pngbin0 -> 989 bytes
-rw-r--r--androidApp/src/main/res/drawable/map_plane.pngbin0 -> 1011 bytes
-rw-r--r--androidApp/src/main/res/drawable/map_scooter.pngbin0 -> 973 bytes
-rw-r--r--androidApp/src/main/res/drawable/map_ship.pngbin0 -> 934 bytes
-rw-r--r--androidApp/src/main/res/drawable/map_tractor.pngbin0 -> 1131 bytes
-rw-r--r--androidApp/src/main/res/drawable/map_train.pngbin0 -> 1031 bytes
-rw-r--r--androidApp/src/main/res/drawable/map_tram.pngbin0 -> 1028 bytes
-rw-r--r--androidApp/src/main/res/drawable/map_trolleybus.pngbin0 -> 986 bytes
-rw-r--r--androidApp/src/main/res/drawable/map_truck.pngbin0 -> 996 bytes
-rw-r--r--androidApp/src/main/res/drawable/map_van.pngbin0 -> 921 bytes
22 files changed, 49 insertions, 16 deletions
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesFragment.kt
index 6beacec..a8782cc 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesFragment.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesFragment.kt
@@ -15,6 +15,7 @@ import mx.trackermap.TrackerMap.android.units.UnitsViewModel
import mx.trackermap.TrackerMap.client.models.UnitInformation
import org.koin.androidx.viewmodel.ext.android.viewModel
+@DelicateCoroutinesApi
class DevicesFragment : Fragment() {
private var _binding: DevicesFragmentBinding? = null
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 125d525..f3d7cac 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
@@ -1,12 +1,14 @@
package mx.trackermap.TrackerMap.android.map
import android.graphics.BitmapFactory
+import android.graphics.Point
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.mousebird.maply.*
+import io.ktor.util.*
import kotlinx.coroutines.DelicateCoroutinesApi
import mx.trackermap.TrackerMap.android.R
import mx.trackermap.TrackerMap.android.databinding.MapFragmentBinding
@@ -57,21 +59,6 @@ class MapFragment: GlobeMapFragment() {
val longitude = -100.36 * Math.PI / 180
val zoom = 0.4
mapControl.animatePositionGeo(longitude, latitude, zoom, 1.0)
-
- insertMarkers()
- }
-
- private fun insertMarkers() {
- val markerInfo = MarkerInfo()
- val icon = BitmapFactory.decodeResource(activity!!.resources, R.drawable.map_default)
- val markerSize = Point2d(80.0, 80.0)
-
- val moscow = ScreenMarker()
- moscow.loc = Point2d.FromDegrees(37.616667, 55.75)
- moscow.image = icon
- moscow.size = markerSize
-
- mapControl.addScreenMarker(moscow, markerInfo, ThreadMode.ThreadAny)
}
override fun onDestroyView() {
@@ -88,7 +75,52 @@ class MapFragment: GlobeMapFragment() {
@DelicateCoroutinesApi
private fun setupObservers() {
unitsViewModel.units.observe(this) { units ->
- Log.d("MapFragment", "Success $units")
+ units.forEach { unit ->
+ unit.position?.let { position ->
+ if (position.longitude != null && position.longitude != null) {
+
+ /* Add marker */
+ val markerInfo = MarkerInfo()
+ val icon =
+ BitmapFactory.decodeResource(
+ activity!!.resources,
+ when (unit.device.category?.lowercase()) {
+ "animal" -> R.drawable.map_animal
+ "bicycle" -> R.drawable.map_bicycle
+ "boat" -> R.drawable.map_boat
+ "bus" -> R.drawable.map_bus
+ "car" -> R.drawable.map_car
+ "crane" -> R.drawable.map_crane
+ "default" -> R.drawable.map_default
+ "helicopter" -> R.drawable.map_helicopter
+ "motorcycle" -> R.drawable.map_motorcycle
+ "offroad" -> R.drawable.map_offroad
+ "person" -> R.drawable.map_person
+ "pickup" -> R.drawable.map_pickup
+ "plane" -> R.drawable.map_plane
+ "scooter" -> R.drawable.map_scooter
+ "ship" -> R.drawable.map_ship
+ "tractor" -> R.drawable.map_tractor
+ "train" -> R.drawable.map_train
+ "tram" -> R.drawable.map_tram
+ "trolleybus" -> R.drawable.map_trolleybus
+ "truck" -> R.drawable.map_truck
+ "van" -> R.drawable.map_van
+ else -> R.drawable.map_default
+ }
+ )
+ val markerSize = Point2d(144.0, 144.0)
+
+ val marker = ScreenMarker()
+ marker.loc = Point2d.FromDegrees(position.longitude!!, position.latitude!!)
+ marker.image = icon
+ marker.size = markerSize
+ marker.userObject = unit
+
+ mapControl.addScreenMarker(marker, markerInfo, ThreadMode.ThreadAny)
+ }
+ }
+ }
}
}
} \ No newline at end of file
diff --git a/androidApp/src/main/res/drawable/map_animal.png b/androidApp/src/main/res/drawable/map_animal.png
new file mode 100644
index 0000000..c6b1043
--- /dev/null
+++ b/androidApp/src/main/res/drawable/map_animal.png
Binary files differ
diff --git a/androidApp/src/main/res/drawable/map_bicycle.png b/androidApp/src/main/res/drawable/map_bicycle.png
new file mode 100644
index 0000000..12956f1
--- /dev/null
+++ b/androidApp/src/main/res/drawable/map_bicycle.png
Binary files differ
diff --git a/androidApp/src/main/res/drawable/map_boat.png b/androidApp/src/main/res/drawable/map_boat.png
new file mode 100644
index 0000000..392f903
--- /dev/null
+++ b/androidApp/src/main/res/drawable/map_boat.png
Binary files differ
diff --git a/androidApp/src/main/res/drawable/map_bus.png b/androidApp/src/main/res/drawable/map_bus.png
new file mode 100644
index 0000000..5bade66
--- /dev/null
+++ b/androidApp/src/main/res/drawable/map_bus.png
Binary files differ
diff --git a/androidApp/src/main/res/drawable/map_car.png b/androidApp/src/main/res/drawable/map_car.png
new file mode 100644
index 0000000..17c97a2
--- /dev/null
+++ b/androidApp/src/main/res/drawable/map_car.png
Binary files differ
diff --git a/androidApp/src/main/res/drawable/map_crane.png b/androidApp/src/main/res/drawable/map_crane.png
new file mode 100644
index 0000000..44d22bc
--- /dev/null
+++ b/androidApp/src/main/res/drawable/map_crane.png
Binary files differ
diff --git a/androidApp/src/main/res/drawable/map_helicopter.png b/androidApp/src/main/res/drawable/map_helicopter.png
new file mode 100644
index 0000000..4c602f1
--- /dev/null
+++ b/androidApp/src/main/res/drawable/map_helicopter.png
Binary files differ
diff --git a/androidApp/src/main/res/drawable/map_motorcycle.png b/androidApp/src/main/res/drawable/map_motorcycle.png
new file mode 100644
index 0000000..01e50cc
--- /dev/null
+++ b/androidApp/src/main/res/drawable/map_motorcycle.png
Binary files differ
diff --git a/androidApp/src/main/res/drawable/map_offroad.png b/androidApp/src/main/res/drawable/map_offroad.png
new file mode 100644
index 0000000..38a99ce
--- /dev/null
+++ b/androidApp/src/main/res/drawable/map_offroad.png
Binary files differ
diff --git a/androidApp/src/main/res/drawable/map_person.png b/androidApp/src/main/res/drawable/map_person.png
new file mode 100644
index 0000000..ed15d09
--- /dev/null
+++ b/androidApp/src/main/res/drawable/map_person.png
Binary files differ
diff --git a/androidApp/src/main/res/drawable/map_pickup.png b/androidApp/src/main/res/drawable/map_pickup.png
new file mode 100644
index 0000000..20c49dd
--- /dev/null
+++ b/androidApp/src/main/res/drawable/map_pickup.png
Binary files differ
diff --git a/androidApp/src/main/res/drawable/map_plane.png b/androidApp/src/main/res/drawable/map_plane.png
new file mode 100644
index 0000000..f5840c6
--- /dev/null
+++ b/androidApp/src/main/res/drawable/map_plane.png
Binary files differ
diff --git a/androidApp/src/main/res/drawable/map_scooter.png b/androidApp/src/main/res/drawable/map_scooter.png
new file mode 100644
index 0000000..61995ae
--- /dev/null
+++ b/androidApp/src/main/res/drawable/map_scooter.png
Binary files differ
diff --git a/androidApp/src/main/res/drawable/map_ship.png b/androidApp/src/main/res/drawable/map_ship.png
new file mode 100644
index 0000000..1e5e48b
--- /dev/null
+++ b/androidApp/src/main/res/drawable/map_ship.png
Binary files differ
diff --git a/androidApp/src/main/res/drawable/map_tractor.png b/androidApp/src/main/res/drawable/map_tractor.png
new file mode 100644
index 0000000..57d2f05
--- /dev/null
+++ b/androidApp/src/main/res/drawable/map_tractor.png
Binary files differ
diff --git a/androidApp/src/main/res/drawable/map_train.png b/androidApp/src/main/res/drawable/map_train.png
new file mode 100644
index 0000000..94ef26c
--- /dev/null
+++ b/androidApp/src/main/res/drawable/map_train.png
Binary files differ
diff --git a/androidApp/src/main/res/drawable/map_tram.png b/androidApp/src/main/res/drawable/map_tram.png
new file mode 100644
index 0000000..9daf131
--- /dev/null
+++ b/androidApp/src/main/res/drawable/map_tram.png
Binary files differ
diff --git a/androidApp/src/main/res/drawable/map_trolleybus.png b/androidApp/src/main/res/drawable/map_trolleybus.png
new file mode 100644
index 0000000..c0db490
--- /dev/null
+++ b/androidApp/src/main/res/drawable/map_trolleybus.png
Binary files differ
diff --git a/androidApp/src/main/res/drawable/map_truck.png b/androidApp/src/main/res/drawable/map_truck.png
new file mode 100644
index 0000000..319f76e
--- /dev/null
+++ b/androidApp/src/main/res/drawable/map_truck.png
Binary files differ
diff --git a/androidApp/src/main/res/drawable/map_van.png b/androidApp/src/main/res/drawable/map_van.png
new file mode 100644
index 0000000..7be109e
--- /dev/null
+++ b/androidApp/src/main/res/drawable/map_van.png
Binary files differ