Skip to content

Commit

Permalink
fix follow user location #507
Browse files Browse the repository at this point in the history
  • Loading branch information
liodali committed Mar 18, 2024
1 parent 5716e18 commit 67faf54
Show file tree
Hide file tree
Showing 4 changed files with 235 additions and 119 deletions.
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ android {
}
dependencies {

def coroutines_version ="1.7.1"
def coroutines_version ="1.7.3"

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
Expand All @@ -87,7 +87,7 @@ dependencies {
//implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"

implementation 'org.osmdroid:osmdroid-android:6.1.17'
implementation 'org.osmdroid:osmdroid-android:6.1.18'
implementation 'com.github.MKergall:osmbonuspack:6.9.0'
implementation 'com.google.android.material:material:1.11.0'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,10 @@ class FlutterOsmView(
}

"user#position" -> {
when (gpsServiceManager.isProviderEnabled(GPS_PROVIDER)) {
when (gpsServiceManager.isProviderEnabled(GPS_PROVIDER)
|| gpsServiceManager.isProviderEnabled(
NETWORK_PROVIDER
)) {
true ->
getUserLocation(result)

Expand Down Expand Up @@ -638,6 +641,7 @@ class FlutterOsmView(
val arrowIcon = (args["arrowDirectionIcon"] as ByteArray)
customPersonMarkerIcon = personIcon.toBitmap()
customArrowMarkerIcon = arrowIcon.toBitmap()
setMarkerTracking()
mapSnapShot().setUserTrackMarker(
personMarker = personIcon, arrowMarker = arrowIcon
)
Expand Down Expand Up @@ -1105,21 +1109,26 @@ class FlutterOsmView(


//locationNewOverlay!!.setPersonIcon()
setMarkerTracking()/*if (!locationNewOverlay.isMyLocationEnabled) {
/*if (!locationNewOverlay.isMyLocationEnabled) {
isEnabled = true
locationNewOverlay.enableMyLocation()
}
mapSnapShot().setEnableMyLocation(isEnabled)*/
if (!map!!.overlays.contains(locationNewOverlay)) {
map!!.overlays.add(locationNewOverlay)
}
locationNewOverlay.enableMyLocation()
locationNewOverlay.runOnFirstFix {
scope!!.launch(Main) {
val currentPosition = GeoPoint(locationNewOverlay.currentLocation)
map!!.controller.animateTo(currentPosition)
val currentPosition = locationNewOverlay.mGeoPoint

map!!.controller.stopAnimation(true)
map!!.controller.setCenter(currentPosition)
//map!!.controller.animateTo(currentPosition)
}

}
if (!map!!.overlays.contains(locationNewOverlay)) {
map!!.overlays.add(locationNewOverlay)
}


}

Expand All @@ -1131,20 +1140,22 @@ class FlutterOsmView(
try {
if (homeMarker != null) {
folderMarkers.items.remove(homeMarker)
map?.invalidate()
}
if (locationNewOverlay.isMyLocationEnabled) {
locationNewOverlay.disableMyLocation()
}

map?.invalidate()
/*if (locationNewOverlay.isMyLocationEnabled) {
locationNewOverlay.disableMyLocation()
}*/

locationNewOverlay.disableRotateDirection = disableRotation
if (!locationNewOverlay.isMyLocationEnabled) {
if (!locationNewOverlay.mIsLocationEnabled) {
isEnabled = true
locationNewOverlay.enableMyLocation()
mapSnapShot().setEnableMyLocation(isEnabled)
}
locationNewOverlay.toggleFollow(enableStopFollow)
when {
locationNewOverlay.isFollowLocationEnabled -> {
locationNewOverlay.mIsFollowing -> {
isTracking = true
locationNewOverlay.onChangedLocation { userLocation ->
scope?.launch {
Expand Down
Loading

0 comments on commit 67faf54

Please sign in to comment.