Correct Marker Flag

This commit is contained in:
clement
2024-07-17 12:52:22 +02:00
parent fd3ecdc255
commit c718551215

View File

@@ -22,40 +22,29 @@ class RetrieveRoad(private var map: MapView,
private var context: Context private var context: Context
) : ) :
AsyncTask<String, Void, Void>() { AsyncTask<String, Void, Void>() {
val icons = intArrayOf( val icons = HashMap<Int, Int>()
com.example.busroute.R.drawable.ic_continue, private fun setIcons(){
com.example.busroute.R.drawable.ic_slight_right, icons.put(1,com.example.busroute.R.drawable.ic_continue)
com.example.busroute.R.drawable.ic_turn_right, icons.put(6,com.example.busroute.R.drawable.ic_slight_right)
com.example.busroute.R.drawable.ic_sharp_right, icons.put(7,com.example.busroute.R.drawable.ic_turn_right)
0, icons.put(8,com.example.busroute.R.drawable.ic_sharp_right)
com.example.busroute.R.drawable.ic_sharp_left, icons.put(12,com.example.busroute.R.drawable.ic_u_turn)
com.example.busroute.R.drawable.ic_turn_left, icons.put(5,com.example.busroute.R.drawable.ic_sharp_left)
com.example.busroute.R.drawable.ic_slight_left, icons.put(4,com.example.busroute.R.drawable.ic_turn_left)
com.example.busroute.R.drawable.ic_u_turn, icons.put(3,com.example.busroute.R.drawable.ic_slight_left)
com.example.busroute.R.drawable.ic_u_turn, icons.put(24,com.example.busroute.R.drawable.ic_arrived)
0, icons.put(27,com.example.busroute.R.drawable.ic_roundabout)
0, icons.put(28,com.example.busroute.R.drawable.ic_roundabout)
0, icons.put(29,com.example.busroute.R.drawable.ic_roundabout)
0, icons.put(30,com.example.busroute.R.drawable.ic_roundabout)
0, icons.put(31,com.example.busroute.R.drawable.ic_roundabout)
0, icons.put(32,com.example.busroute.R.drawable.ic_roundabout)
0, icons.put(33,com.example.busroute.R.drawable.ic_roundabout)
0, icons.put(34,com.example.busroute.R.drawable.ic_roundabout)
0, }
0,
0,
0,
0,
0,
com.example.busroute.R.drawable.ic_roundabout,
com.example.busroute.R.drawable.ic_roundabout,
com.example.busroute.R.drawable.ic_roundabout,
com.example.busroute.R.drawable.ic_roundabout,
com.example.busroute.R.drawable.ic_roundabout,
com.example.busroute.R.drawable.ic_roundabout
)
override fun doInBackground(vararg p0: String): Void? { override fun doInBackground(vararg p0: String): Void? {
this.setIcons()
val roadManager: RoadManager = OSRMRoadManager(context, "me") val roadManager: RoadManager = OSRMRoadManager(context, "me")
val waypoints = ArrayList<GeoPoint>() val waypoints = ArrayList<GeoPoint>()
waypoints.add(GeoPoint(latitude, longitude)) waypoints.add(GeoPoint(latitude, longitude))
@@ -77,13 +66,12 @@ class RetrieveRoad(private var map: MapView,
nodeMarker.title = "Step $i" nodeMarker.title = "Step $i"
nodeMarker.snippet = node.mInstructions nodeMarker.snippet = node.mInstructions
nodeMarker.subDescription = Road.getLengthDurationText(context, node.mLength, node.mDuration) nodeMarker.subDescription = Road.getLengthDurationText(context, node.mLength, node.mDuration)
val id = icons[node.mManeuverType] val id: Int? = icons.get(node.mManeuverType)
if (id != 0){ if (id != null){
val icon: Drawable? = context.getDrawable(id) val icon: Drawable? = context.getDrawable(id)
nodeMarker.image = icon nodeMarker.image = icon
map.overlays.add(nodeMarker)
} }
map.overlays.add(nodeMarker)
} }
return null return null
} }