Use Location "Needle" as the the endpoint marker (see #95)

master
y20k 2021-03-08 15:18:12 +01:00
parent 3f9dd74797
commit 5a75b3fc3d
No known key found for this signature in database
GPG Key ID: 824D4259F41FAFF6
4 changed files with 38 additions and 35 deletions

View File

@ -88,20 +88,18 @@ class MapOverlayHelper (private var markerListener: MarkerListener) {
/* Creates icon overlay for track */
fun createTrackOverlay(context: Context, track: Track, trackingState: Int): ItemizedIconOverlay<OverlayItem> {
fun createTrackOverlay(context: Context, track: Track, trackingState: Int, displayEndMarker: Boolean = false): ItemizedIconOverlay<OverlayItem> {
val overlayItems: ArrayList<OverlayItem> = ArrayList<OverlayItem>()
val wayPoints: MutableList<WayPoint> = track.wayPoints
val maxIndex: Int = wayPoints.size - 1
wayPoints.forEachIndexed { index: Int, wayPoint: WayPoint ->
// create marker
val newMarker: Drawable
// get drawable
when (trackingState) {
// CASE: Recording is active
Keys.STATE_TRACKING_ACTIVE -> {
when (trackingState) {
// CASE: Recording is active
Keys.STATE_TRACKING_ACTIVE -> {
wayPoints.forEach { wayPoint: WayPoint ->
// get drawable
val newMarker: Drawable
if (wayPoint.starred) {
newMarker = ContextCompat.getDrawable(context, R.drawable.ic_star_red_24dp)!!
} else if (wayPoint.isStopOver) {
@ -109,10 +107,18 @@ class MapOverlayHelper (private var markerListener: MarkerListener) {
} else {
newMarker = ContextCompat.getDrawable(context, R.drawable.ic_marker_track_location_red_24dp)!!
}
// create overlay item and add to list of overlay items
val overlayItem: OverlayItem = createOverlayItem(context, wayPoint.latitude, wayPoint.longitude, wayPoint.accuracy, wayPoint.provider, wayPoint.time)
overlayItem.setMarker(newMarker)
overlayItems.add(overlayItem)
}
// CASE: Recording is paused/stopped
else -> {
if (index == maxIndex) {
}
// CASE: Recording is paused/stopped
else -> {
wayPoints.forEachIndexed { index: Int, wayPoint: WayPoint ->
// get drawable
val newMarker: Drawable
if (displayEndMarker && index == maxIndex) {
if (wayPoint.starred) {
newMarker = ContextCompat.getDrawable(context, R.drawable.ic_marker_track_end_starred_blue_36dp)!!
} else {
@ -126,15 +132,13 @@ class MapOverlayHelper (private var markerListener: MarkerListener) {
} else {
newMarker = ContextCompat.getDrawable(context, R.drawable.ic_marker_track_location_blue_24dp)!!
}
// create overlay item and add to list of overlay items
val overlayItem: OverlayItem = createOverlayItem(context, wayPoint.latitude, wayPoint.longitude, wayPoint.accuracy, wayPoint.provider, wayPoint.time)
overlayItem.setMarker(newMarker)
overlayItems.add(overlayItem)
}
}
// create overlay item and add to list of overlay items
val overlayItem: OverlayItem = createOverlayItem(context, wayPoint.latitude, wayPoint.longitude, wayPoint.accuracy, wayPoint.provider, wayPoint.time)
overlayItem.setMarker(newMarker)
overlayItems.add(overlayItem)
}
// create and return overlay for current position
return createOverlay(context, overlayItems)
}

View File

@ -146,7 +146,7 @@ data class TrackFragmentLayoutHolder(private var context: Context, private var m
mapView.overlays.add(compassOverlay)
// create map overlay
trackOverlay = MapOverlayHelper(markerListener).createTrackOverlay(context, track, Keys.STATE_TRACKING_NOT)
trackOverlay = MapOverlayHelper(markerListener).createTrackOverlay(context, track, Keys.STATE_TRACKING_NOT, displayEndMarker = true)
if (track.wayPoints.isNotEmpty()) {
mapView.overlays.add(trackOverlay)
}

View File

@ -1,14 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="36dp"
android:height="36dp"
android:viewportWidth="144"
android:viewportHeight="144">
<path
android:pathData="M72,72m-24,0a24,24 0,1 1,48 0a24,24 0,1 1,-48 0"
android:fillColor="#3c98db"
/>
<path
android:pathData="m107.715,8.24 l-1.694,-8.471L67.903,-0.23L67.903,71.77L76.374,71.77L76.374,42.123h23.718l1.694,8.471h29.647L131.433,8.24Z"
android:strokeWidth="4.23529"
android:fillColor="#3c98db"/>
android:width="36dp"
android:viewportHeight="144"
android:viewportWidth="144">
<path android:fillColor="@color/trackbook_blue"
android:pathData="M72,72m-24,0a24,24 0,1 1,48 0a24,24 0,1 1,-48 0"/>
<path android:fillColor="@color/trackbook_red"
android:pathData="M72.02,0C58.088,0 46.82,11.268 46.82,25.2 46.82,44.1 72.02,72 72.02,72c0,0 25.2,-27.9 25.2,-46.8C97.22,11.268 85.952,0 72.02,0ZM72.02,34.2c-4.968,0 -9,-4.032 -9,-9 0,-4.968 4.032,-9 9,-9 4.968,0 9,4.032 9,9 0,4.968 -4.032,9 -9,9z" android:strokeWidth="3.60001"/>
</vector>

View File

@ -1,7 +1,10 @@
<vector android:height="36dp" android:viewportHeight="144"
android:viewportWidth="144" android:width="36dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#3c98db"
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="36dp"
android:width="36dp"
android:viewportHeight="144"
android:viewportWidth="144">
<path android:fillColor="@color/trackbook_blue"
android:pathData="M72,95.08 L96.72,110 90.16,81.88 112,62.96 83.24,60.52 72,34 60.76,60.52 32,62.96 53.84,81.88 47.28,110Z" android:strokeWidth="16.9412"/>
<path android:fillColor="#3c98db"
android:pathData="m107.715,8.24 l-1.694,-8.471L67.903,-0.23L67.903,71.77L76.374,71.77L76.374,42.123h23.718l1.694,8.471h29.647L131.433,8.24Z" android:strokeWidth="4.23529"/>
<path android:fillColor="@color/trackbook_red"
android:pathData="M72.02,0C58.088,0 46.82,11.268 46.82,25.2 46.82,44.1 72.02,72 72.02,72c0,0 25.2,-27.9 25.2,-46.8C97.22,11.268 85.952,0 72.02,0ZM72.02,34.2c-4.968,0 -9,-4.032 -9,-9 0,-4.968 4.032,-9 9,-9 4.968,0 9,4.032 9,9 0,4.968 -4.032,9 -9,9z" android:strokeWidth="3.60001"/>
</vector>