Skip to content

Commit 816bb86

Browse files
committed
feat: display different icons for start and end stop on map
1 parent 1c554ca commit 816bb86

File tree

3 files changed

+101
-13
lines changed

3 files changed

+101
-13
lines changed

app/src/main/java/net/youapps/transport/screens/TripDetailsScreen.kt

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -132,21 +132,51 @@ fun TripDetailsScreen(
132132
val trainStations = remember {
133133
trip.legs.flatMap { listOf(it.departure, it.arrival) }.distinct()
134134
}
135-
val trainStationsSource = rememberGeoJsonSource(
136-
data = GeoJsonData.Features(featureCollection {
137-
trainStations.forEach { station ->
138-
feature(Point(station.geoPosition())) {
139-
put("name", station.uniqueShortName())
135+
136+
if (trainStations.size >= 2) {
137+
val firstStationSource = rememberGeoJsonSource(
138+
data = GeoJsonData.Features(featureCollection {
139+
feature(Point(trainStations.first().geoPosition())) {
140+
put("name", trainStations.first().uniqueShortName())
140141
}
141-
}
142-
})
143-
)
142+
})
143+
)
144+
SymbolLayer(
145+
id = "start_station",
146+
source = firstStationSource,
147+
iconImage = image(painterResource(R.drawable.ic_geo_marker))
148+
)
144149

145-
SymbolLayer(
146-
id = "stations",
147-
source = trainStationsSource,
148-
iconImage = image(painterResource(R.drawable.ic_geo_marker))
149-
)
150+
val intermediateStationsSource = rememberGeoJsonSource(
151+
data = GeoJsonData.Features(featureCollection {
152+
trainStations.subList(1, trainStations.size - 1).forEach { station ->
153+
feature(Point(station.geoPosition())) {
154+
put("name", station.uniqueShortName())
155+
}
156+
}
157+
})
158+
)
159+
160+
SymbolLayer(
161+
id = "intermediate_stations",
162+
source = intermediateStationsSource,
163+
iconImage = image(painterResource(R.drawable.ic_swap)),
164+
minZoom = 7f
165+
)
166+
167+
val lastStationSource = rememberGeoJsonSource(
168+
data = GeoJsonData.Features(featureCollection {
169+
feature(Point(trainStations.last().geoPosition())) {
170+
put("name", trainStations.last().uniqueShortName())
171+
}
172+
})
173+
)
174+
SymbolLayer(
175+
id = "end_station",
176+
source = lastStationSource,
177+
iconImage = image(painterResource(R.drawable.ic_destination))
178+
)
179+
}
150180

151181
val tripSectionsSource = rememberGeoJsonSource(
152182
data = GeoJsonData.Features(featureCollection {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="30dp"
3+
android:height="46dp"
4+
android:viewportWidth="451"
5+
android:viewportHeight="512.43">
6+
7+
<group
8+
android:scaleY="0.5"
9+
android:scaleX="0.6"
10+
android:translateX="200">
11+
12+
<path
13+
android:fillColor="#E21B1B"
14+
android:fillType="evenOdd"
15+
android:pathData="M56.64,62.99C247.61,-69.01 263.46,191.83 451,28.7v266.2C272.13,455.75 231.95,196.3 56.64,328.37V62.99z" />
16+
17+
<path
18+
android:fillColor="#4F1A08"
19+
android:fillType="evenOdd"
20+
android:pathData="M57.16,62.94v386.54c8.16,6.46 13.39,16.45 13.39,27.66 0,19.49 -15.79,35.28 -35.28,35.28C15.79,512.43 0,496.63 0,477.14c0,-11.89 5.88,-22.4 14.89,-28.79V64.07C5.88,57.68 0,47.17 0,35.28 0,15.8 15.79,0 35.28,0c19.49,0 35.28,15.8 35.28,35.28 0,11.22 -5.23,21.2 -13.39,27.66z" />
21+
22+
</group>
23+
</vector>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="56dp"
4+
android:viewportWidth="512"
5+
android:viewportHeight="512">
6+
7+
<group
8+
android:scaleY="0.5">
9+
10+
<path
11+
android:fillColor="#F2CA7F"
12+
android:pathData="M8.23,294.08l131.26,96.9l0,-40.77l185.77,0l0,-112.25l-185.77,0l0,-40.77z" />
13+
14+
<path
15+
android:fillColor="#FF000000"
16+
android:pathData="M78.79,335.4l-56.71,-41.87l109.18,-80.61v24.48c0,4.54 3.68,8.23 8.23,8.23h19.29c4.54,0 8.23,-3.68 8.23,-8.23s-3.68,-8.23 -8.23,-8.23h-11.07v-32.56c0,-3.11 -1.75,-5.95 -4.52,-7.34c-2.77,-1.4 -6.09,-1.12 -8.59,0.73L3.34,286.92c-2.1,1.55 -3.34,4.01 -3.34,6.62c0,2.61 1.24,5.07 3.34,6.62l65.68,48.48c1.47,1.09 3.18,1.61 4.88,1.61c2.52,0 5.01,-1.16 6.63,-3.34C83.22,343.25 82.44,338.1 78.79,335.4z" />
17+
18+
<path
19+
android:fillColor="#FF000000"
20+
android:pathData="M325.25,294.34c-4.54,0 -8.23,3.68 -8.23,8.23v38.87H139.48c-4.54,0 -8.23,3.68 -8.23,8.23v24.47l-23.58,-17.41c-3.65,-2.7 -8.81,-1.92 -11.5,1.73c-2.7,3.66 -1.92,8.81 1.73,11.51l36.7,27.09c1.44,1.06 3.16,1.61 4.89,1.61c1.26,0 2.54,-0.29 3.71,-0.88c2.77,-1.4 4.52,-4.24 4.52,-7.34v-32.54h177.54c4.54,0 8.23,-3.68 8.23,-8.23V302.57C333.47,298.02 329.79,294.34 325.25,294.34z" />
21+
22+
<path
23+
android:fillColor="#E0B76E"
24+
android:pathData="M171.95,237.96h153.3v51.99h-153.3z" />
25+
26+
<path
27+
android:fillColor="#8CC1EA"
28+
android:pathData="M503.77,219.01l-131.25,-96.9l0,40.77l-185.77,0l0,112.25l185.77,0l0,40.77z" />
29+
30+
<path
31+
android:fillColor="#FF000000"
32+
android:pathData="M508.66,211.85l-131.25,-96.9c-2.5,-1.84 -5.82,-2.13 -8.59,-0.73c-2.77,1.4 -4.52,4.24 -4.52,7.34v32.55H257.69c-4.54,0 -8.23,3.68 -8.23,8.23s3.68,8.23 8.23,8.23h114.83c4.54,0 8.23,-3.68 8.23,-8.23v-24.48l109.18,80.6l-109.18,80.6v-24.47c0,-4.54 -3.68,-8.23 -8.23,-8.23H194.98v-95.8h35.29c4.54,0 8.23,-3.68 8.23,-8.23s-3.68,-8.23 -8.23,-8.23h-43.51c-4.54,0 -8.23,3.68 -8.23,8.23v112.25c0,4.54 3.68,8.23 8.23,8.23h177.54v32.55c0,3.11 1.75,5.95 4.52,7.34c1.17,0.59 2.44,0.88 3.71,0.88c1.73,0 3.44,-0.54 4.89,-1.61l131.25,-96.9c2.1,-1.55 3.34,-4.01 3.34,-6.62C512,215.85 510.76,213.4 508.66,211.85z" />
33+
34+
</group>
35+
</vector>

0 commit comments

Comments
 (0)