Use Location "Needle" as the the endpoint marker (see #95)
This commit is contained in:
parent
3f9dd74797
commit
5a75b3fc3d
4 changed files with 38 additions and 35 deletions
|
@ -88,20 +88,18 @@ class MapOverlayHelper (private var markerListener: MarkerListener) {
|
||||||
|
|
||||||
|
|
||||||
/* Creates icon overlay for track */
|
/* 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 overlayItems: ArrayList<OverlayItem> = ArrayList<OverlayItem>()
|
||||||
val wayPoints: MutableList<WayPoint> = track.wayPoints
|
val wayPoints: MutableList<WayPoint> = track.wayPoints
|
||||||
val maxIndex: Int = wayPoints.size - 1
|
val maxIndex: Int = wayPoints.size - 1
|
||||||
|
|
||||||
wayPoints.forEachIndexed { index: Int, wayPoint: WayPoint ->
|
|
||||||
// create marker
|
|
||||||
val newMarker: Drawable
|
|
||||||
|
|
||||||
// get drawable
|
|
||||||
when (trackingState) {
|
when (trackingState) {
|
||||||
// CASE: Recording is active
|
// CASE: Recording is active
|
||||||
Keys.STATE_TRACKING_ACTIVE -> {
|
Keys.STATE_TRACKING_ACTIVE -> {
|
||||||
|
wayPoints.forEach { wayPoint: WayPoint ->
|
||||||
|
// get drawable
|
||||||
|
val newMarker: Drawable
|
||||||
if (wayPoint.starred) {
|
if (wayPoint.starred) {
|
||||||
newMarker = ContextCompat.getDrawable(context, R.drawable.ic_star_red_24dp)!!
|
newMarker = ContextCompat.getDrawable(context, R.drawable.ic_star_red_24dp)!!
|
||||||
} else if (wayPoint.isStopOver) {
|
} else if (wayPoint.isStopOver) {
|
||||||
|
@ -109,10 +107,18 @@ class MapOverlayHelper (private var markerListener: MarkerListener) {
|
||||||
} else {
|
} else {
|
||||||
newMarker = ContextCompat.getDrawable(context, R.drawable.ic_marker_track_location_red_24dp)!!
|
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
|
// CASE: Recording is paused/stopped
|
||||||
else -> {
|
else -> {
|
||||||
if (index == maxIndex) {
|
wayPoints.forEachIndexed { index: Int, wayPoint: WayPoint ->
|
||||||
|
// get drawable
|
||||||
|
val newMarker: Drawable
|
||||||
|
if (displayEndMarker && index == maxIndex) {
|
||||||
if (wayPoint.starred) {
|
if (wayPoint.starred) {
|
||||||
newMarker = ContextCompat.getDrawable(context, R.drawable.ic_marker_track_end_starred_blue_36dp)!!
|
newMarker = ContextCompat.getDrawable(context, R.drawable.ic_marker_track_end_starred_blue_36dp)!!
|
||||||
} else {
|
} else {
|
||||||
|
@ -126,15 +132,13 @@ class MapOverlayHelper (private var markerListener: MarkerListener) {
|
||||||
} else {
|
} else {
|
||||||
newMarker = ContextCompat.getDrawable(context, R.drawable.ic_marker_track_location_blue_24dp)!!
|
newMarker = ContextCompat.getDrawable(context, R.drawable.ic_marker_track_location_blue_24dp)!!
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// create overlay item and add to list of overlay items
|
// 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)
|
val overlayItem: OverlayItem = createOverlayItem(context, wayPoint.latitude, wayPoint.longitude, wayPoint.accuracy, wayPoint.provider, wayPoint.time)
|
||||||
overlayItem.setMarker(newMarker)
|
overlayItem.setMarker(newMarker)
|
||||||
overlayItems.add(overlayItem)
|
overlayItems.add(overlayItem)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// create and return overlay for current position
|
// create and return overlay for current position
|
||||||
return createOverlay(context, overlayItems)
|
return createOverlay(context, overlayItems)
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,7 @@ data class TrackFragmentLayoutHolder(private var context: Context, private var m
|
||||||
mapView.overlays.add(compassOverlay)
|
mapView.overlays.add(compassOverlay)
|
||||||
|
|
||||||
// create map overlay
|
// 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()) {
|
if (track.wayPoints.isNotEmpty()) {
|
||||||
mapView.overlays.add(trackOverlay)
|
mapView.overlays.add(trackOverlay)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:width="36dp"
|
|
||||||
android:height="36dp"
|
android:height="36dp"
|
||||||
android:viewportWidth="144"
|
android:width="36dp"
|
||||||
android:viewportHeight="144">
|
android:viewportHeight="144"
|
||||||
<path
|
android:viewportWidth="144">
|
||||||
android:pathData="M72,72m-24,0a24,24 0,1 1,48 0a24,24 0,1 1,-48 0"
|
<path android:fillColor="@color/trackbook_blue"
|
||||||
android:fillColor="#3c98db"
|
android:pathData="M72,72m-24,0a24,24 0,1 1,48 0a24,24 0,1 1,-48 0"/>
|
||||||
/>
|
<path android:fillColor="@color/trackbook_red"
|
||||||
<path
|
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"/>
|
||||||
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"/>
|
|
||||||
</vector>
|
</vector>
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
<vector android:height="36dp" android:viewportHeight="144"
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:viewportWidth="144" android:width="36dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
android:height="36dp"
|
||||||
<path android:fillColor="#3c98db"
|
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"/>
|
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"
|
<path android:fillColor="@color/trackbook_red"
|
||||||
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: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>
|
</vector>
|
||||||
|
|
Loading…
Reference in a new issue