diff options
Diffstat (limited to 'androidApp/src')
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 Binary files differnew file mode 100644 index 0000000..c6b1043 --- /dev/null +++ b/androidApp/src/main/res/drawable/map_animal.png diff --git a/androidApp/src/main/res/drawable/map_bicycle.png b/androidApp/src/main/res/drawable/map_bicycle.png Binary files differnew file mode 100644 index 0000000..12956f1 --- /dev/null +++ b/androidApp/src/main/res/drawable/map_bicycle.png diff --git a/androidApp/src/main/res/drawable/map_boat.png b/androidApp/src/main/res/drawable/map_boat.png Binary files differnew file mode 100644 index 0000000..392f903 --- /dev/null +++ b/androidApp/src/main/res/drawable/map_boat.png diff --git a/androidApp/src/main/res/drawable/map_bus.png b/androidApp/src/main/res/drawable/map_bus.png Binary files differnew file mode 100644 index 0000000..5bade66 --- /dev/null +++ b/androidApp/src/main/res/drawable/map_bus.png diff --git a/androidApp/src/main/res/drawable/map_car.png b/androidApp/src/main/res/drawable/map_car.png Binary files differnew file mode 100644 index 0000000..17c97a2 --- /dev/null +++ b/androidApp/src/main/res/drawable/map_car.png diff --git a/androidApp/src/main/res/drawable/map_crane.png b/androidApp/src/main/res/drawable/map_crane.png Binary files differnew file mode 100644 index 0000000..44d22bc --- /dev/null +++ b/androidApp/src/main/res/drawable/map_crane.png diff --git a/androidApp/src/main/res/drawable/map_helicopter.png b/androidApp/src/main/res/drawable/map_helicopter.png Binary files differnew file mode 100644 index 0000000..4c602f1 --- /dev/null +++ b/androidApp/src/main/res/drawable/map_helicopter.png diff --git a/androidApp/src/main/res/drawable/map_motorcycle.png b/androidApp/src/main/res/drawable/map_motorcycle.png Binary files differnew file mode 100644 index 0000000..01e50cc --- /dev/null +++ b/androidApp/src/main/res/drawable/map_motorcycle.png diff --git a/androidApp/src/main/res/drawable/map_offroad.png b/androidApp/src/main/res/drawable/map_offroad.png Binary files differnew file mode 100644 index 0000000..38a99ce --- /dev/null +++ b/androidApp/src/main/res/drawable/map_offroad.png diff --git a/androidApp/src/main/res/drawable/map_person.png b/androidApp/src/main/res/drawable/map_person.png Binary files differnew file mode 100644 index 0000000..ed15d09 --- /dev/null +++ b/androidApp/src/main/res/drawable/map_person.png diff --git a/androidApp/src/main/res/drawable/map_pickup.png b/androidApp/src/main/res/drawable/map_pickup.png Binary files differnew file mode 100644 index 0000000..20c49dd --- /dev/null +++ b/androidApp/src/main/res/drawable/map_pickup.png diff --git a/androidApp/src/main/res/drawable/map_plane.png b/androidApp/src/main/res/drawable/map_plane.png Binary files differnew file mode 100644 index 0000000..f5840c6 --- /dev/null +++ b/androidApp/src/main/res/drawable/map_plane.png diff --git a/androidApp/src/main/res/drawable/map_scooter.png b/androidApp/src/main/res/drawable/map_scooter.png Binary files differnew file mode 100644 index 0000000..61995ae --- /dev/null +++ b/androidApp/src/main/res/drawable/map_scooter.png diff --git a/androidApp/src/main/res/drawable/map_ship.png b/androidApp/src/main/res/drawable/map_ship.png Binary files differnew file mode 100644 index 0000000..1e5e48b --- /dev/null +++ b/androidApp/src/main/res/drawable/map_ship.png diff --git a/androidApp/src/main/res/drawable/map_tractor.png b/androidApp/src/main/res/drawable/map_tractor.png Binary files differnew file mode 100644 index 0000000..57d2f05 --- /dev/null +++ b/androidApp/src/main/res/drawable/map_tractor.png diff --git a/androidApp/src/main/res/drawable/map_train.png b/androidApp/src/main/res/drawable/map_train.png Binary files differnew file mode 100644 index 0000000..94ef26c --- /dev/null +++ b/androidApp/src/main/res/drawable/map_train.png diff --git a/androidApp/src/main/res/drawable/map_tram.png b/androidApp/src/main/res/drawable/map_tram.png Binary files differnew file mode 100644 index 0000000..9daf131 --- /dev/null +++ b/androidApp/src/main/res/drawable/map_tram.png diff --git a/androidApp/src/main/res/drawable/map_trolleybus.png b/androidApp/src/main/res/drawable/map_trolleybus.png Binary files differnew file mode 100644 index 0000000..c0db490 --- /dev/null +++ b/androidApp/src/main/res/drawable/map_trolleybus.png diff --git a/androidApp/src/main/res/drawable/map_truck.png b/androidApp/src/main/res/drawable/map_truck.png Binary files differnew file mode 100644 index 0000000..319f76e --- /dev/null +++ b/androidApp/src/main/res/drawable/map_truck.png diff --git a/androidApp/src/main/res/drawable/map_van.png b/androidApp/src/main/res/drawable/map_van.png Binary files differnew file mode 100644 index 0000000..7be109e --- /dev/null +++ b/androidApp/src/main/res/drawable/map_van.png |