From c718551215ccf7c8ddefadc9e27053b573a04a2f Mon Sep 17 00:00:00 2001 From: clement Date: Wed, 17 Jul 2024 12:52:22 +0200 Subject: [PATCH] Correct Marker Flag --- .../java/com/example/busroute/RetrieveRoad.kt | 60 ++++++++----------- 1 file changed, 24 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/com/example/busroute/RetrieveRoad.kt b/app/src/main/java/com/example/busroute/RetrieveRoad.kt index d0dbd52..f713165 100644 --- a/app/src/main/java/com/example/busroute/RetrieveRoad.kt +++ b/app/src/main/java/com/example/busroute/RetrieveRoad.kt @@ -22,40 +22,29 @@ class RetrieveRoad(private var map: MapView, private var context: Context ) : AsyncTask() { - val icons = intArrayOf( - com.example.busroute.R.drawable.ic_continue, - com.example.busroute.R.drawable.ic_slight_right, - com.example.busroute.R.drawable.ic_turn_right, - com.example.busroute.R.drawable.ic_sharp_right, - 0, - com.example.busroute.R.drawable.ic_sharp_left, - com.example.busroute.R.drawable.ic_turn_left, - com.example.busroute.R.drawable.ic_slight_left, - com.example.busroute.R.drawable.ic_u_turn, - com.example.busroute.R.drawable.ic_u_turn, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 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 - ) + val icons = HashMap() + private fun setIcons(){ + icons.put(1,com.example.busroute.R.drawable.ic_continue) + icons.put(6,com.example.busroute.R.drawable.ic_slight_right) + icons.put(7,com.example.busroute.R.drawable.ic_turn_right) + icons.put(8,com.example.busroute.R.drawable.ic_sharp_right) + icons.put(12,com.example.busroute.R.drawable.ic_u_turn) + icons.put(5,com.example.busroute.R.drawable.ic_sharp_left) + icons.put(4,com.example.busroute.R.drawable.ic_turn_left) + icons.put(3,com.example.busroute.R.drawable.ic_slight_left) + icons.put(24,com.example.busroute.R.drawable.ic_arrived) + icons.put(27,com.example.busroute.R.drawable.ic_roundabout) + icons.put(28,com.example.busroute.R.drawable.ic_roundabout) + icons.put(29,com.example.busroute.R.drawable.ic_roundabout) + icons.put(30,com.example.busroute.R.drawable.ic_roundabout) + icons.put(31,com.example.busroute.R.drawable.ic_roundabout) + icons.put(32,com.example.busroute.R.drawable.ic_roundabout) + icons.put(33,com.example.busroute.R.drawable.ic_roundabout) + icons.put(34,com.example.busroute.R.drawable.ic_roundabout) + } override fun doInBackground(vararg p0: String): Void? { + this.setIcons() val roadManager: RoadManager = OSRMRoadManager(context, "me") val waypoints = ArrayList() waypoints.add(GeoPoint(latitude, longitude)) @@ -77,13 +66,12 @@ class RetrieveRoad(private var map: MapView, nodeMarker.title = "Step $i" nodeMarker.snippet = node.mInstructions nodeMarker.subDescription = Road.getLengthDurationText(context, node.mLength, node.mDuration) - val id = icons[node.mManeuverType] - if (id != 0){ + val id: Int? = icons.get(node.mManeuverType) + if (id != null){ val icon: Drawable? = context.getDrawable(id) nodeMarker.image = icon - map.overlays.add(nodeMarker) - } + map.overlays.add(nodeMarker) } return null }