Test azimuth
This commit is contained in:
@@ -14,8 +14,7 @@
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.BusRoute"
|
||||
tools:targetApi="31">
|
||||
android:theme="@style/Theme.BusRoute">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.Manifest
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.AlertDialog
|
||||
import android.content.Intent
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.location.Location
|
||||
import android.location.LocationManager
|
||||
@@ -31,6 +32,7 @@ import org.osmdroid.util.GeoPoint
|
||||
import org.osmdroid.views.MapView
|
||||
import org.osmdroid.views.overlay.Marker
|
||||
import org.osmdroid.views.overlay.compass.CompassOverlay
|
||||
import org.osmdroid.views.overlay.compass.IOrientationProvider
|
||||
import org.osmdroid.views.overlay.compass.InternalCompassOrientationProvider
|
||||
import org.osmdroid.views.overlay.gestures.RotationGestureOverlay
|
||||
import org.osmdroid.views.overlay.mylocation.GpsMyLocationProvider
|
||||
@@ -53,6 +55,7 @@ class MainActivity : ComponentActivity() {
|
||||
|
||||
private var latitude = 0.0
|
||||
private var longitude = 0.0
|
||||
private var navigationEnable = false
|
||||
private var busStopList: ArrayList<BusStop> = ArrayList()
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
@@ -60,6 +63,7 @@ class MainActivity : ComponentActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
isLocationPermissionGranted()
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||
val dbHelper = DbHelper(this)
|
||||
val tts = TextToSpeech(this, TextToSpeech.OnInitListener{})
|
||||
tts.setVoice(Voice("French",
|
||||
@@ -142,6 +146,9 @@ class MainActivity : ComponentActivity() {
|
||||
latitude = location.latitude
|
||||
longitude = location.longitude
|
||||
mapController.animateTo(GeoPoint(latitude, longitude))
|
||||
if(navigationEnable){
|
||||
map.mapOrientation = -compassOverlay.azimuthOffset
|
||||
}
|
||||
|
||||
findViewById<TextView>(R.id.accuracy).text = "${location.accuracy} %"
|
||||
}
|
||||
@@ -151,8 +158,8 @@ class MainActivity : ComponentActivity() {
|
||||
map.overlays.add(locationOverlay)
|
||||
val roadButton = findViewById<Button>(R.id.road)
|
||||
roadButton.setOnClickListener {
|
||||
tts.speak("Dans 500 mètres, tourner à droite", TextToSpeech.QUEUE_FLUSH, null,"")
|
||||
locationOverlay.disableMyLocation()
|
||||
navigationEnable = true
|
||||
tts.speak("Début de l'itinéraire", TextToSpeech.QUEUE_FLUSH, null,"")
|
||||
RetrieveRoad(map, latitude,longitude, roadButton.context).execute()
|
||||
}
|
||||
|
||||
|
||||
@@ -67,11 +67,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: Int? = icons.get(node.mManeuverType)
|
||||
if (id != null){
|
||||
val icon: Drawable? = context.getDrawable(id)
|
||||
nodeMarker.image = icon
|
||||
var id: Int? = icons.get(node.mManeuverType)
|
||||
if (id == null){
|
||||
id = icons.get(1)
|
||||
}
|
||||
val icon: Drawable? = context.getDrawable(id!!)
|
||||
nodeMarker.image = icon
|
||||
map.overlays.add(nodeMarker)
|
||||
}
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user