Skip to content

Commit 94d1735

Browse files
committed
feat : 목적지와 처음 현재 위치 축적 구현
1 parent 20dab98 commit 94d1735

File tree

5 files changed

+30
-19
lines changed

5 files changed

+30
-19
lines changed

presentation/src/main/java/com/stop/ui/mission/MissionFragment.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,15 @@ class MissionFragment : Fragment(), MissionHandler {
172172
}
173173
1 -> {
174174
beforeLocation = userLocation
175-
tMap.tMapView.setCenterPoint(userLocation.latitude, userLocation.longitude)
176175
tMap.addMarker(
177176
Marker.PERSON_MARKER,
178177
Marker.PERSON_MARKER_IMG,
179178
TMapPoint(userLocation.latitude, userLocation.longitude)
180179
)
181180
viewModel.personCurrentLocation = userLocation
181+
tMap.latitudes.add(userLocation.latitude)
182+
tMap.longitudes.add(userLocation.longitude)
183+
tMap.setRouteDetailFocus()
182184
first += 1
183185
}
184186
else -> {
@@ -206,6 +208,8 @@ class MissionFragment : Fragment(), MissionHandler {
206208

207209
private fun makeDestinationMarker() {
208210
tMap.addMarker(Marker.DESTINATION_MARKER, Marker.DESTINATION_MARKER_IMG, TEST_DESTINATION)
211+
tMap.latitudes.add(TEST_DESTINATION.latitude)
212+
tMap.longitudes.add(TEST_DESTINATION.longitude)
209213
}
210214

211215
companion object {

presentation/src/main/java/com/stop/ui/routedetail/RouteDetailTMap.kt

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ import com.stop.ui.util.TMap
1212

1313
class RouteDetailTMap(
1414
private val context: Context,
15-
private val handler: RouteDetailHandler,
15+
handler: RouteDetailHandler,
1616
) : TMap(context, handler) {
1717
private val tMapPoints = arrayListOf<TMapPoint>()
18-
private val latitudes = arrayListOf<Double>()
19-
private val longitudes = arrayListOf<Double>()
2018

2119
private var polyLine = TMapPolyLine()
2220

@@ -76,23 +74,12 @@ class RouteDetailTMap(
7674
convertToTMapPoint(routes.first().start.coordinate)
7775
)
7876
addMarker(
79-
Marker.DESTINATION_MARKER,
80-
Marker.DESTINATION_MARKER_IMG,
77+
Marker.END_MARKER,
78+
Marker.END_MARKER_IMG,
8179
convertToTMapPoint(routes.last().end.coordinate)
8280
)
8381
}
8482

85-
private fun setRouteDetailFocus() {
86-
val maxLatitude = latitudes.max()
87-
val minLatitude = latitudes.min()
88-
val maxLongitude = longitudes.max()
89-
val minLongitude = longitudes.min()
90-
91-
tMapView.setCenterPoint((maxLatitude + minLatitude) / 2, (maxLongitude + minLongitude) / 2)
92-
tMapView.zoomToSpan(maxLatitude - minLatitude, maxLongitude - minLongitude)
93-
tMapView.zoomLevel -= 1
94-
}
95-
9683
private fun addTMapPoints(point: TMapPoint) {
9784
tMapPoints.add(point)
9885
latitudes.add(point.latitude)

presentation/src/main/java/com/stop/ui/util/Marker.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ object Marker {
1010
const val START_MARKER = "start_marker"
1111
const val START_MARKER_IMG = R.drawable.ic_start_marker
1212

13-
const val DESTINATION_MARKER = "destination_marker"
14-
const val DESTINATION_MARKER_IMG = R.drawable.ic_destination_marker
13+
const val END_MARKER = "end_marker"
14+
const val END_MARKER_IMG = R.drawable.ic_destination_marker
1515

1616
const val PERSON_MARKER = "person_marker"
1717
const val PERSON_MARKER_IMG = R.drawable.ic_person_marker

presentation/src/main/java/com/stop/ui/util/TMap.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ open class TMap(
2020
lateinit var tMapView: TMapView
2121
lateinit var initLocation: Location
2222

23+
val latitudes = arrayListOf<Double>()
24+
val longitudes = arrayListOf<Double>()
25+
2326
var isTracking = true
2427

2528
fun init() {
@@ -94,4 +97,16 @@ open class TMap(
9497
tMapView.removeTMapMarkerItem(id)
9598
tMapView.addTMapMarkerItem(marker)
9699
}
100+
101+
fun setRouteDetailFocus() {
102+
val maxLatitude = latitudes.max()
103+
val minLatitude = latitudes.min()
104+
val maxLongitude = longitudes.max()
105+
val minLongitude = longitudes.min()
106+
107+
tMapView.setCenterPoint((maxLatitude + minLatitude) / 2, (maxLongitude + minLongitude) / 2)
108+
tMapView.zoomToSpan(maxLatitude - minLatitude, maxLongitude - minLongitude)
109+
tMapView.zoomLevel -= 1
110+
}
111+
97112
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="32dp" android:tint="#AD87E7"
2+
android:viewportHeight="24" android:viewportWidth="24"
3+
android:width="32dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="@android:color/white" android:pathData="M15,3l2.3,2.3l-2.89,2.87l1.42,1.42L18.7,6.7L21,9V3H15zM3,9l2.3,-2.3l2.87,2.89l1.42,-1.42L6.7,5.3L9,3H3V9zM9,21l-2.3,-2.3l2.89,-2.87l-1.42,-1.42L5.3,17.3L3,15v6H9zM21,15l-2.3,2.3l-2.87,-2.89l-1.42,1.42l2.89,2.87L15,21h6V15z"/>
5+
</vector>

0 commit comments

Comments
 (0)